如果我申请固定仓位,保证金顶部在ie7中不起作用



如果我在css中使用固定位置,我在ie7中的页边空白顶部有问题。

我在网上搜索了一个解决方案,尝试了很多,但都没有成功。

测试div的margin-top不起作用。

如有任何帮助,我们将不胜感激。

这是我的html

<!DOCTYPE html>
<html lang="en">
<head>
<title> test </title>
<link rel="stylesheet" href="test.css">
<!--[if IE 7]><link rel="stylesheet" href="ie7.css" type="text/css" media="screen"/><![endif]-->

</head>
<body>
<div id="fixed1">
<div id="fixed"></div>
</div>

<div id="test">
ayhd iaudiuawdyiaudyw
</div>
<div class="clear">
</div>
</body>
</html>

这是我的css

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,
pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, 
q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, 
form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
margin : 0;
padding : 0;
border : 0;
outline : 0;
font-weight : inherit;
font-style : inherit;
font-size : 100%;
font-family : inherit;
vertical-align : baseline;}
:focus {
outline : 0;
}
body {
line-height : 1;
color : black;
background : white;
}
ol, ul {
list-style : none;
}
table {
border-collapse : separate;
border-spacing : 0;
}
caption, th, td {
text-align : left;
font-weight : normal;
}

#fixed1 {
position : fixed;
width : 100%;
top : 0;
background-color : red;
}
#fixed {
margin : 0 auto;
height : 20px;
background-color : blue;
width : 980px;
}
#test {
margin : 0 auto;
margin-top : 20px;
margin-bottom : 20px;
height : 2000px;
width : 980px;
background-color : red;
}

这是ie7.css

#fixed1{
left:0px;
}
#test{
margin-top:30px;
background-color:grey;
}

谢谢你,基肖尔。

检查这个小提琴。我已经把你的代码加进去了。它也适用于ie7http://jsfiddle.net/S9AVa/1/

问题是因为以两种方式指定了边距,边距:0自动;以及页边空白顶部和页边空白底部。IE考虑第一个调用。

它应该像

#test {
margin : 20px auto 20px auto;
float:left;
 height : 2000px;
width : 1040px;
background-color : red;
}

并且我已经将CCD_ 1添加到CCD_。

更新的演示http://jsfiddle.net/S9AVa/2/

最新更新