I have 2 divs: one in the left side and one in the right side of my page. The one in the left side has fixed width and I want the one of the right side to f
Since this is a rather popular question, I'm inclined to share a nice solution using BFC.
Codepen sample of the following here.
.left {
float: left;
width: 100px;
}
.right {
overflow: auto;
}
In this case, overflow: auto
triggers context behavior and makes the right element expand only to the available remaining width and it will naturally expand to full width if .left
disappears. A highly useful and clean trick for many UI layouts, but perhaps hard to understand the "why it works" at first.