[英]Center a div in ie7 and ie8
我想简单地将div居中在窗口中间。 目前正在使用
.notSupported { display: block; position: fixed; top: 0; bottom: 0; left: 0; right: 0; max-width: 500px; max-height: 200px; margin: auto; background-color: #f3f3f3; z-index: 1000; text-align: center; }
<div class="notSupported">Your browser is not supported</div>
在ie7
它导致div出现在左上角,并在ie8
居中。
html, body { height: 100%; } #wrapper { position: relative; width: 100%; height: 100%; display: table; } #middle { display: table-cell; vertical-align: middle; text-align: center; } /* for IE7 and below */ #middle { *position: absolute; *top: 50%; *width: 100%; *text-align: center; } #center { *position: relative; *top: -50%; }
<div id="wrapper"> <div id="middle"> <div id="center">Center me !</div> </div> </div>
阻止在IE7中不起作用。
您必须使用zoom:1并将其作为hack阻止,或者仅将ie7作为其他css的hack来阻止。
.notSupported {
display: block;
*display: block;
*zoom:1;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
max-width: 500px;
max-height: 200px;
margin: auto;
background-color: #f3f3f3;
z-index: 1000;
text-align: center;
width:200px;
height:50px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.