I have a container (image gallery) that is max-width:80%. Inside, images are floated left forming columns and rows. As you shrink/expand the browser window, more or fewer images fit into each row and there is typically a "remainder" at the end of each row, when there is not enough space to fit another full image:
http://jsfiddle.net/vladmalik/DRLXE/1/
I'd like the container to expand or contract to exactly hug however many floats fit into a column (so there is never a yellow remainder to the right). Can this be done with CSS?
HTML:
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
CSS:
div {
width: 100px;
height: 100px;
float:left;
background: red;
}
section {
margin: 0 auto;
max-width: 80%;
background:yellow;
overflow: hidden;
}