I have two <div>
‘s inside a flexbox, and I’m trying to make the first <div>
resizable, while the second <div>
should fill the remaining space in the <div>
.
I have functioning code, but the resizable <div>
jumps a bit when you try to resize it (firefox & edge), and I’m not sure why, or how to stop it from doing that ;-;
fiddle: https://jsfiddle.net/cftou6rL/
div {
border: 1px solid black;
}
.container {
display: flex;
flex-direction: column;
background: yellow;
height: 200px;
width: 150px;
}
#div1 {
background: red;
}
#div2 {
background: lightblue;
height: max-content;
overflow-y: scroll;
}
.resizable {
resize: vertical;
overflow: scroll;
}
<div class="container resizable">
<div id="div1" class="resizable">
<p>Div 1</p>
</div>
<div id="div2">
<p>Div 2</p>
<p>Div 2</p>
<p>Div 2</p>
<p>Div 2</p>
</div>
</div>
2
Answers
I fixed the jumping/snapping issue by using a
<grid>
instead of<flex>
(and a bit of duct tape) :/The problem occurs when the container doesn’t have enough space to push div2 down.
So I put the height of the container fixed (not resizable).
but the 2 divs inside it are perfectly resizable as long as their total height doesn’t exceed the height of the parent.