<div id="boxContainerContainer"> <p>---------Top text may vary in height------------</p> <div id="boxContainer"> <div id="box1"></div> <div id="box2"></div> <div id="box3"></div> </div> <p>---------Bottom text may vary in height------------</p> </div> #boxContainerContainer { background: #fdd; text-align: center; } #boxContainer { border:thick dotted #060; margin: 0px auto 10px auto; text-align: left; } #box1 { width: 50px; height: 50px; background: #999; } #box2 { width: 50px; height: 100px; background: #999; } #box3 { width: 50px; height: 50px; background: #999; } #boxContainer, #box1, #box2, #box3 { display: inline-block; vertical-align: top; } /* this rule is for IE7 and below only */ /* put it in a Conditional comment without the !ie7 hack if you wish! */ #boxContainer, #box1, #box2, #box3 { display: inline !ie7; margin: 0 2px !ie7; }
DIV เรียงกัน และอยู่บนติดขอบ
https://stackoverflow.com/questions/5686276/how-to-align-a-div-to-the-top-of-its-parent-but-keeping-its-inline-block-behavio