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

161
Visualizações
Moving a CSS Element Vertically Without JS

Is there anyway I can make an HTML div move down while scrolling instead of moving up without using javascript? I know you can use window.onscroll = function() { } and have that move the position of an object while scrolling, but is there anyway I can move an object down with just CSS and HTML?

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

0

I think you want to retain your div on the viewport while scrolling down.

There are 2 ways for it.

  1. Make the element position fixed and apply positioning to that element.
  2. Make parent element position relative and make your div position sticky and apply positioning.

Positioning means adding any one of the top, right, bottom, and left properties.

.parent {
  height: 1200px;
  width: auto;
  position: relative;
}

.floating {
  position: sticky;
  top: 10px;
  width: 100%;
  height: 60px;
  background: black;
  color: white;
}
<div class="parent">
  <p>Hi this is parent</p>
  <div class="floating">
    This is floating element
  </div>
</div>

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