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

228
Visualizações
Flex container with flex-direction column-reverse will not scroll to top

I am displaying notifications in the following div in order to show the last elements at the top of the container :

<div class="flex h-full max-h-full pt-36">
    <div id="scrollDiv" class="justify-bottom z-20 flex w-full flex-col-reverse items-center overflow-y-scroll scrollbar-thin">
        <div class="notification"></div>
        <div class="notification"></div>
        <div class="notification"></div>
        <div class="notification"></div>
    </div>
</div>

Automatically, when the container overflows, it is scrolled to the bottom. I have tried to set scrollTop using the following Javascript with no success :

function scrollNotifications() {
    var element = document.getElementById('scrollDiv')
    element.scrollTop = element.scrollHeight
}

How can I scroll the container to the top when overflowing on the y axis ?

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

0

The problem was with the scrollTop positioning. The 0 value will scroll to the bottom because of the reverse direction property. The simple trick was to set a negative value :

function scrollNotifications() {
    var element = document.getElementById('scrollDiv')
    element.scrollTop = -element.scrollHeight
}
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