<div class="container">
<div class="box1"></div>
<div class="box2"></div>
</div>
.container {
width: 100%;
height: 200px;
display: flex;
}
.box1 {
width: 25%;
min-width: 400px;
height: 100%;
}
.box2 {
width: 75%;
height: 100%;
}
So what I'm trying to do is make a div
that is 100% width. The child elements will be 25% and 75%. I want the 25% div
to have a min-width
. So I want the 75% div
to automatically adjust to just filling the remaining space when the minimum width brings box1
over 25%.
Neither flex-grow
or flex-shrink
seem to work for me. I don't want box2
to shrink because it should be bigger than box1
for the majority of the time. I don't want box2
to grow because it will also sometimes be smaller than box1
.
FYI: I should note that I'm using this with a slick.js slider. I have my two divs untouched by the plugin though, so my slider is wrapped in an additional container (box2). The slider container is taking 100% width of box 2. I know flex seems to adjust on the fly normally in situations like this, so if I had a paragraph in box2, the width will adjust dynamically, but having the slider seems to be making it really finicky, and it needs the containing box2 to have a width that's working properly.