As can be seen in this JS-Fiddle, I basically try to use this CSS to create two divs that should fullfill these requirements:
- If twice the space of the wider item is available, both should use 50% width (that works)
- If not enough space for both items is available, they should wrap (that works)
- If enough space is available for both items, but less than twice the width of the wider one, the narrower item should shrink (that does NOT work, it wraps)
I don't understand this behavior, because I have set flex-shrink
for the flex items, so they should be able to shrink - but they don't: If the narrower item would be less than 50% wide, it wraps.
.m {
display: flex;
flex-wrap: wrap;
}
.l_1 {
background-color: red;
flex: 1 1 50%;
}
.r_1 {
background-color: yellow;
flex: 1 1 50%;
}
<div class=m>
<div class=l_1>
left_______________________________________________X
</div>
<div class=r_1>
right
</div>
</div>
(Tested on Firefox and Chrome)