Here you go: http://codepen.io/seraphzz/pen/lutjb
The solution to this is:
- Change
.thing
fromfloat: left;
todisplay: inline-block;
. This keeps those elements in line, but also keeps them in flow so the parent element acknowledges it has children - Give
section
awhite-space: nowrap;
property. This prevents the.thing
elements from going to another line. - Give
section
anoverflow-x: auto
property. This allows the div to be scrolled horizontally, but hides the scrollbar if there are not enough children to need it. - Lastly, give
section
afont-size: 0
property. By default, elements that aredisplay: inline-block
are treated like text, and are thus given an automatic margin. Settingfont-size: 0
on the parent of those elements removes that automatic margin, allowing you to set the margin as you like. Remember, you will need to manually set the font-size of these child items if they contain text.