This will do the trick:
#bars {
display: table-cell;
border: solid 1px black;
}
#bars > div {
display: inline-block;
vertical-align: bottom;
width: 5px;
background-color: #999;
margin-left: 2px;
}
#bars > div:first-child {
margin-left: 0;
}
It uses display: table-cell;
on the parent div, which by default has vertical-align: baseline;
applied. This changes the need for float: left;
on the child divs and allows us to use display: 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!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…