我尝试水平居中2个divs并对齐它们之间的这2个div。当我在每个div中放入不同大小的文本时,问题就来了。以下是示例:http://jsfiddle.net/DgEcs/1/中心2文本与文本
为什么红色的div会向下移动以及如何解决?
CSS:
.container{
margin: 20px auto;
height: 50px; line-height: 50px;
text-align: center; /* to center red and blue */
background: whiteSmoke;
}
.red{
display:inline-block; /* to put it side by side */
font-size: 10px;
background:red;
}
.blue{
display:inline-block; /* to put it side by side */
font-size: 26px;
background:blue;
}
HTML:
<div class="container" >
<div class="red"> aaaaaaa </div>
<div class="blue"> bbbbbbb </div>
</div>
好,它的工作原理。你知道为什么会发生?我之前尝试过:vertical-align:center;它不起作用,你明白为什么吗? – Nrc 2013-04-10 14:06:32