Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
Make contents of div scroll to bottom using CSS

Can anyone suggest a way to make the contents of a div (when they exceed the size of the div) to scroll to the bottom.

According to this answer from Jim Hall as refined in comments you can do it by adding an extra div with the following:

display: flex; 
flex-direction: column-reverse

However, this is not working for me (contents just load scrolled to top with bottom content hidden.)

Here is my code:

CSS:

//The point of the next class is to force a scroll to the bottom but it is not working

.chatContainer {
  height: 500px;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
}

.chatContents {
  width: 300px;
  border: solid 1px #EEE;
  display: flex;
  flex-direction: column;
  padding: 10px;
  max-height: 500px;
  overflow-y: scroll;
}

HTML:

<div class="chatContainer">
<div class="chatContents">
<div id = "bubbles"></div>
</div>
</div>

Would appreciate any suggestions on how to do this in pure CSS or with simple javascript (no jquery etc.)

Thanks for any suggestions.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try limiting the size of the div which contains the chatbox kind of how i did in the following code:

var element = document.getElementById("chatbox");
element.scrollTop = element.scrollHeight;
.chatContainer {
  height: 500px;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
}

.chatContents {
  width: 300px;
  border: solid 1px #EEE;
  display: flex;
  flex-direction: column;
  padding: 10px;
  max-height: 500px;
  overflow-y: scroll;
  height: 25vh;
  overflow-x: hidden;
}
<div class="chatContainer">
  <div class="chatContents" id="chatbox">
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
        <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hello
    </div>
    <div id = "bubbles">
      hellodjfdjfhdjfhsdhskfhsdkhfsdkhfjsdhf
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda