0
我想保持我的容器div文本对齐居中,无论其中的div的大小。嵌套的div定位与css
<div id="container">
I want to stay at the center
<div id="right-content">Right div effects centered content
</div>
</div>
#container {
text-align:center;
background-color: #888;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
min-width: 500px;
height: 65px;
margin-top: 60px;
}
#right-content {
background-color:#F00;
display:block;
vertical-align:middle;
float:right;
height: 65px;
color:#FFF;
}
抱歉,右键内容附接。
没有不垂直,其实我想要做的是什么样的下面的代码,但是这并不能有效地安排与静态values.there利润率应该是这个简单的方法。
#container {
text-align:center;
background-color: #888;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
width: 750px;
height: 65px;
margin-top: 60px;
}
#right-content {
background-color:#F00;
float:right;
height: 65px;
color:#FFF;
position: absolute;
margin-top: -20px;
margin-left: 535px;
}
的DIV是一样的。
它已经居中。你的意思是垂直居中? –
你忘了包含'#right-content' css吗? – KidTempo