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

151
Visualizações
How to stop react component from going past the top of the page when scrolling

I want to make it do that when a user scrolls down a page, one of my react components reaches the top of the page, and stays there, not going any further up.

Imgur link to 'intranet' app im building: https://imgur.com/a/nWdDOrC

In the image, the component with the thick red border should stay at the top of the page when scrolling, with a margin. Tried fixing position, but I don't want it static, just not scrollable past the top of the page.

There are other similar questions, but none that seem to tackle this particular problem exactly - please correct me if I'm wrong.

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

0

You should look at the sticky position in css.

A sticky element toggles between relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).

.component {
  position: sticky;
  top: 0;
}

ref: https://www.w3schools.com/howto/howto_css_sticky_element.asp

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