I want the container div (#a-container in this example) to fit the width of its children, that are inline-block divs. In this example, I want the #a-container d
#a-container
Here's a fiddle that uses display: table and floating: http://jsfiddle.net/vqjnoqur/.
display: table
HTML:
#a-container { display: table; background-color: gray; } .a { background-color:blue; width:100px; height: 100px; margin: 5px; float: left; } .a:nth-of-type(2n + 1) { clear: left; }