【发布时间】:2015-06-21 04:46:01
【问题描述】:
我是 CSS 方面的大新手,但我尝试了不同的方法,但我无法让我的 div 垂直居中。
家长:
#ModalScroll{
position:absolute;
top:0;
left:0;
z-index:1001;
height:1px;
width:1px;
overflow:hidden;
display:none;
font-size:100%;
text-align:left;
}
孩子:
.ModalDialog{
border:1px solid #3C4749;
background-color:#FFF;
margin:0 auto 0 auto;
display:none;
font-size: 12px;
box-sizing: border-box;
width: 280px;
height: 160px;
position: absolute;
left: 50%;
top: 50%;
margin: -80px 0 0 -140px;
}
我不知道 jQuery 中的解决方案是否应该更好,但我更喜欢 CSS 中的解决方案。
【问题讨论】:
-
我已经看过并尝试过这两种方法。
标签: jquery html css internet-explorer centering