Because examples rule: http://jsfiddle.net/rudiedirkx/wgue7/
How do I get the bars to the bottom instead of the top? Now they’re sticking to the top of the container (#bars) but I want them sticking to the bottom.
As you can see, I don’t know the height of the highest bar, so I don’t know the height of the container.
These q+a don’t help: Vertically align floating divs, Vertically align floating DIVs
Should be simple, right? If it helps: it only has to work in decent browsers.
PS. Number of bars is variable (not in the example) and their heights are. Only their widths are static. Positioning absolute won’t help, because the container div doesn’t have measurements.
This will do the trick:
It uses
display: table-cell;on the parent div, which by default hasvertical-align: baseline;applied. This changes the need forfloat: left;on the child divs and allows us to usedisplay: inline-block;. This also removes the need for your CSS clear fix.EDIT – Per @thirtydot’s comments, adding
vertical-align: bottom;to the child divs removes the gap at the bottom.Therefore, I changed CSS above and jsFiddle. I kept the
display: table-cell;so that the parent div wraps the child divs with 0 padding and looks nice and snazzy!