I have a nav
bar and a main
area that is divided to 2 equal halves, left
and right
.
When the left
half contains a wide
element that overflows its width, the 50/50 division of main
breaks, causing left
to take more than 50%.
Why is this happening?
How could I avoid that?
.container {
display: flex;
height: 100px;
background-color: #ccc;
width: 300px;
}
nav {
flex-shrink: 0;
background-color: #aaa;
}
main {
display: flex;
flex: 1;
}
.left {
flex: 1 0 50%;
background-color: #bbb;
overflow: auto;
}
.wide {
width: 300px;
}
.right {
flex: 1 0 50%;
}
<div class="container">
<nav>Navigation</nav>
<main>
<div class="left">
<div class="wide">Left</div>
</div>
<div class="right">Right</div>
</main>
</div>