I have two divs that display vertically on top of each other. Both divs expand 100% width. I am searching for a way for the height of the bottom div to be determined by the content that exists inside of it, and the height of the top div to dynamically resize itself so that its height is the same height as the bottom div.
The top div has a small amount of text and the bottom div has a large amount of text. Obviously, as the screen size shrinks and the text wraps the divs become longer. For example, as the screen size shrinks and the bottom div with a significant amount of text becomes longer than the top div, the top div should increase in size.
I know that something like this could be accomplished with javascript by dynamically setting the height of the divs through an event listener or something similar, but I am searching for a way that could be accomplished with html and css.
I have tried flex grow and experimenting with a percentage based height and neither have been effective. I would greatly appreciate any insight anyone might have!
.container {
display: flex;
flex-direction: column;
}
.b1 {
background-color: red;
height: 50%;
}
.b2 {
background-color: orange;
height: 50%;
}
.box {
flex-grow: 1;
}
<div class="container">
<div class="box b1">One</div>
<div class="box b2">
DIV B Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>