Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
Floating Action Button not sticked to its parent element

I'm using Material UI v4 libraries to build a React Js app.

I create a custom Floating Action Button (FAB) component.

The FAB component (the red box in the picture below) must be sticked to the bottom right (with some margins) of its parent element which is the Flyout component (the blue box in the picture below).

The Fylout component has some children inside of it. They are the title, the Content component (sample Card component from Material UI), and the FAB component.

The Flyout component must have an absolute position and be scrollable (scroll: 'auto') for its root element because of some reason (I couldn't mention them here).

I use absolute position for the FAB component. The result is fine (when the Card is not expanded) as seen in the screenshot below:

enter image description here

But when the Card component is expanded and we scroll the Flyout component, the FAB component is not sticked more from its parent as seen in the screenshot below:

enter image description here

I tried to use position: 'sticky' for the FAB component with bottom: 20 and right: 20, but the FAB is not sticked to the bottom right of the Flyout component as seen in the screenshot below:

enter image description here

So my question is how to make the FAB button sticked only to the bottom right of the Flyout component?

Here is the simplified code: https://codesandbox.io/s/fab-stick-to-parent-w5ng3

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Since I don't have enough reputation to comment, I have to make this an answer.

Replacing position: absolute; with position: fixed; worked for me.

An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.

Final code:

makeStyles-addButton-9 {
    right: 40px;
    bottom: 40px;
    position: fixed;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda