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.