请查看:垂直居中在另一个元素的元素在Internet Explorer
我想使用边距移动灰箱在JS小提琴以上。
我希望灰盒子在黑盒子的中间,但我被告知margin-top与Internet Explorer不兼容。
我该用什么来代替?
谢谢!在元素上
请查看:垂直居中在另一个元素的元素在Internet Explorer
我想使用边距移动灰箱在JS小提琴以上。
我希望灰盒子在黑盒子的中间,但我被告知margin-top与Internet Explorer不兼容。
我该用什么来代替?
谢谢!在元素上
使用边距吧:)
我不知道为什么你需要使用margin-top
做这个任务之前。这可以帮助你:
.one {
background: #151515;
height: 700px;
width: 900px;
margin: 0px auto;
padding: 0px 0px 0px 0px;
display:table-cell;
vertical-align:middle;
}
使用display: table-cell
不会IE6-7工作。如果这是你所关心,你可以使用以下方法:
.one {
background: #151515;
height: 700px;
width: 900px;
margin: 0px auto;
padding: 0px 0px 0px 0px;
position: relative;
}
.two {
background: #e6e6e6;
height: 140px;
width: 900px;
position: absolute;
top: 50%;
margin-top: -70px; /* half of the height */
}
为什么IE有问题的margin-top? – Nix