我想对齐绝对定位的div。顶部:50%,底部:50%不工作,这有什么解决方案?如何垂直放置绝对定位的物品?
CSS
#container {
position:relative;
background:red;
width:600px;
height:600px;
}
#cen {
position:absolute;
width:300px;
height:300px;
background:grey;
top:50%;
bottom:50%;
}
HTML
<div id="container">
<div id="cen"></div>
</div>
'top:50%'将元素的顶部边缘设置为从其第一个非静态位置父元素的顶部减少50%。 – 2013-04-24 20:21:35