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