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

224
Visualizações
Scroll element up instead of scrolling page down

I have a page that currently consists of a nav bar, a page header and the body/content. I've been looking for a way to have the body scroll up into/over the header instead of the entire page scrolling down. I'm not sure if that's the right way to word it as I'm sure someone would have asked this before but I can't find anything related to it.

As it is now, the header has text in the center and, when a user scrolls, loses space above the text. What I'd like is for the header to lose space below the text, effectively having scroll pull the body content up over the header.

Although it may not be of help, this is the code I'm working with

<Page>
  <Header>
      <h1 className={styles.titleText}>HEADER TITLE</h1>
      <p>Header sub text</p>
  </Header>
  <Body>
    <h1>This is where I would put some content ... if I was even slightly creative</h1>
  </Body>
</Page>

Where Page, Header and Body are arbitarily styled componets for reuse on most pages and the navbar is inside _app as it's wanted on every page. I understand this may not be the best way, or even a very good way of doing things but I'm still learning and making mistakes as I go.

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

0

So I found the answer was to add position: fixed to my header and ensuring that it's z-index placed it behind the body. I also added an element the same size as my header that isn't position: fixed to reserve the space for the header when the user is scrolled to the top.

If you have the same problem, please know I am still learning as of writing and this may not be the best solution.

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