Reputation: 79
I have a pen, that i mustered up. I have a panel-section with square divs inside it, with a column direction, but for some reason I cannot make that panel section scrollable to accommodate the divs inside with there heights. I tried overflow-y: auto, but it does not behave as it should. Right now the boxes just shrink into position.
.panel-section {
flex-basis: 18vw;
background-color: #BFFD19;
padding-top: 15px;
padding-left: 15px;
padding-right: 30px;
min-height: 0px;
display: flex;
flex-direction: column;
.thumbnail-holder {
margin-bottom: 15px;
background-color: #6036AD;
width: 95%;
height: 160px;
}
}
}
https://codepen.io/anon/pen/OzKKgy
the panel-section (to the right) and the boxes are thumbnail holder. I have read other articles on overflow, but those techniques didnt work for me.
Upvotes: 3
Views: 9558
Reputation: 87191
To make the .panel-section
scrollable, add overflow: auto
to its rule.
And then, as a flex item's default flex-shrink
value is 1
, which means it is set to shrink to fit its parent, add flex-shrink: 0
the .thumbnail-holder
, and they will keep their height.
Additionally, a fix, which i.a. Firefox need, is to set min-height: 0;
on the .top-section
, allowing it to be smaller than its content.
Note, to avoid a vertical scrollbar on the viewport, and easier see the scrollbar on .panel-section
, I changed the inline style on the modal-content
element to width:100%
(%
instead of vw
).
Stack snippet
.modal-content {
display: flex;
flex-direction: column;
}
.modal-content .top-section {
background-color: #2EC55C;
flex-grow: 1;
min-height: 0;
display: flex;
}
.modal-content .top-section .content-section {
flex-grow: 1;
background-color: #6733FC;
display: flex;
flex-direction: column;
}
.modal-content .top-section .content-section .title-section {
background-color: #21DE71;
flex-basis: 10vh;
}
.modal-content .top-section .content-section .beer-section {
background-color: #FA64FF;
flex-grow: 1;
display: flex;
}
.modal-content .top-section .content-section .beer-section .image-section {
background-color: #90FF00;
flex-basis: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.modal-content .top-section .content-section .beer-section .image-section .image-container {
background-color: #FBA02B;
height: 72vh;
width: 55vh;
}
.modal-content .top-section .content-section .beer-section .text-section {
background-color: #F63333;
flex-basis: 50%;
}
.modal-content .top-section .panel-section {
flex-basis: 18vw;
background-color: #BFFD19;
padding-top: 15px;
padding-left: 15px;
padding-right: 30px;
min-height: 0px;
display: flex;
flex-direction: column;
overflow: auto;
}
.modal-content .top-section .panel-section .thumbnail-holder {
margin-bottom: 15px;
background-color: #6036AD;
width: 95%;
height: 160px;
flex-shrink: 0;
}
.modal-content .bottom-section {
background-color: #4283FA;
flex-basis: 10vh;
}
@media (max-width: 1100px) {
.modal-content .top-section .panel-section {
flex-basis: 25vw;
}
}
@media (max-width: 450px) {
.modal-content .top-section .panel-section {
display: none;
}
}
<div class="modal-content" style="height:100vh;width:100%;">
<div class="top-section">
<div class="content-section">
<div class="title-section">
</div>
<div class="beer-section">
<div class="image-section">
<div class="image-container">
</div>
</div>
<div class="text-section">
</div>
</div>
</div>
<div class="panel-section">
<div class="thumbnail-holder">
</div>
<div class="thumbnail-holder">
</div>
<div class="thumbnail-holder">
</div>
<div class="thumbnail-holder">
</div>
<div class="thumbnail-holder">
</div>
</div>
</div>
<div class="bottom-section">
</div>
</div>
Upvotes: 5