见:http://jsfiddle.net/b2BpB/1/
问:如何让box1和box3对齐到父divboxContainer
的顶部?
#boxContainerContainer {
background: #fdd;
text-align: center;
}
#boxContainer {
display: inline-block;
border: thick dotted #060;
margin: 0px auto 10px auto;
text-align: left;
}
#box1 {
width: 50px;
height: 50px;
background: #999;
display: inline-block;
}
#box2 {
width: 50px;
height: 100px;
background: #999;
display: inline-block;
}
#box3 {
width: 50px;
height: 50px;
background: #999;
display: inline-block;
}
帮助非常感谢...
致谢:这个问题来自 https://stackoverflow.com/users/20578/paul-d-waite 之前给出的答案。 : Getting a CSS element to automatically resize to content width, and at the same time be centered
最佳答案
试试 vertical-align
CSS 属性。
#box1 {
width: 50px;
height: 50px;
background: #999;
display: inline-block;
vertical-align: top; /* here */
}
也将它应用到 #box3
。
https://stackoverflow.com/questions/5686276/