M
M
Miron4ek_2282022-02-16 23:56:03
css
Miron4ek_228, 2022-02-16 23:56:03

How to make a flex container scroll?

Here is the code - https://codepen.io/Menson/pen/XWzzOoB?editors=1100

When I set chat to display: block - there is a scroll, but when I change it to flex - the scroll does not work.
To make sure of this, it is enough to duplicate the spans.

It is important for me that there is exactly flex, because in this case the messages are initially pressed to the bottom.

It is necessary, when adding new spans, to make the scroll work. How can i do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LJ322, 2022-02-17
@Miron4ek_228

This might work for your idea. Make the wrapper flex, and the block inside, in which spans are displayed, a regular block

.wrapper {
  display: flex;
  flex-direction: column;
  justify-content: end;
  width: 700px;
  height: 150px;
}
.chat {
  display: block;
  overflow-y: scroll;
}

F
FeST1Val, 2022-02-17
@FeST1Val

Add class scrollable to wrapper

.scrollable {
    height: 150px;
    overflow-y: scroll;
    width: 700px;
}
.chat {
  display: flex;
  flex-direction: column;
  justify-content: end;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question