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

279
Vistas
Height too small when using display: flex and flex-direction: column

I am trying to make a chat section with all the elements already mapped and shown (react):

<div className="localChat">
{messages.map(({ id, message }) => (
      <div style={{
      backgroundColor: message.userSent === user.email ? "#dcf8c6" : "#F5F5F5",
      borderTopLeftRadius: message.userSent !== user.email ? "0px" : "8px",
      borderTopRightRadius: message.userSent !== user.email ? "8px" : "0px",
      alignSelf: message.userSent === user.email ? "flex-end" : "flex-start"
    }} className="chat-message">
        <strong className="chat-message-text">{message.text}</strong>
        <p className="chat-message-date">{new Date(message.timestamp.toDate()).toLocaleString()}</p>
      </div>
    ))}
    </div>

There is nothing wrong with any of the timestamps or text. They are all being mapped properly.

I am trying to align it so if I sent it it would be on right and if another user sent it it would be of left and it would be different colors. All of this works apart from aligning it.

Here is the class styles I used:

.localChat {
height: 65vh;
margin-top: 20px;
width: 80vw;
background-color: white;
margin-bottom: 20px;
margin-left: auto;
margin-right: auto;
border-radius: 8px;
box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
overflow-y: scroll;
scroll-behavior: smooth;
flex: 1;
display: flex;
flex-direction: column;
overflow-y: scroll;
}

And here is the message css

.chat-message {
  display: flex;
  margin: 15px 30px 15px 30px;
  flex-direction: column;
  position: relative;
  width: fit-content;
  max-width: 400px;
  padding: 10px;
  background-color: #F3F3F3;
  border-radius: 10px;
  height: fit-content;
  box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
}

.chat-message-text {
  text-align: left;
  font-size: 13px;
  margin-bottom: 10px;
}

.chat-message-date {
  font-size: 11px;
  color: gray;
  font-weight: normal;
  align-self: flex-end;
}

For some reason my messages heights are so small and scrollbars apear. enter image description here

I cant even see the text. once again, there is no error with the mapping and getting the text and timestamp. Something is wrong with css. Please help.

about 4 years ago · Juan Pablo Isaza
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