见: http://jsfiddle.net/b2BpB/1/
问: 如何使 box1和 box3与父 div boxContainer
的顶部对齐?
#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: 让 CSS 元素自动调整到内容宽度,同时居中之前给出的答案