我有一个相对div定位在一个固定的位置div上,我想垂直对齐这第一个div。有没有办法做到这一点?这是我目前的标记:将div与固定div垂直对齐作为父级?
<div class="overlay">
<div id="dialogInvoice">
content
</div>
</div>
的CSS:
.overlay {
height: 100%;
width: 100%;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.5);
position: fixed;
z-index: 10;
}
#dialogInvoice {
width: 390px;
height: 722px;
margin: 0 auto;
padding-top: 28px;
border-radius: 4px;
background: #ffffff;
position: relative;
}
对此有何建议?我确实尝试了行高度方法,但这显然只在使用纯文本时才起作用。
你能举一个你的目标的例子吗? –
https://lh6.googleusercontent.com/-VkKe-DFuEsw/TYTXFh3fJuI/AAAAAAAABRI/9rBS08RlJJc/s1600/Screen+shot+2011-03-19+at+9.47.03+PM.png – 2339870
是否需要#dialognvoice “位置:亲属”?你可以这样做,如果你使用position:absolute并设置top:100px和bottom:100px也许 –