Making an element take 100% height and scrollable
I have a setup similar to:
I need the list to take the remaining height of
.child-2
yet also be scrollable
Currently, the list takes as much height as it needs while being constrained to .parent
's height, making .parent
's "internal" height increase
According to my testing, the issue seems to lie in max-height: 100%
4 Replies
My first doubt is the parent class , why does it have max height and not just height, because if u set it to max height , the issue will persist till there are enough list items , but if u set parents height and then inside the child-2 set another wrapper for all the list items and set it's height to 100% with overflow-y : scroll , I think what ur going for will work
Funny enough, this sketch actually works, but in my project it doesn't for some reason (although the HTML structure in my project is not you exactly the same) https://codepen.io/avi12641/pen/wvZQpNR
A friend helped me solve it and the solution was setting the parent as
display: flex; flex-direction: column
and give the list min-height: 0
Nice
Mark it as solved if it's done