ie6,ie7,ie8完美支持position:fixed的终极解决方案,ie7ie8


ie6对position:fixed不支持,网上有很多解决方法,有的在ie6,ie7上调试成功后,在ie8上又不好使,div层还是跟随滚动条浮 动;以下总结方法,在ie6,ie7,ie8上都调试成功,且页面滚动条滚动时,效果还挺好,div层并不会闪烁。

复制代码 代码如下:

<div id="goTop_div" class="fixed ie">  </div>

css:

复制代码 代码如下:

.fixed{
        position:fixed; /*对于火狐等其他浏览器需要设置的*/
        top:700px;  /*同上*/
        width:30px;
        height:30px;
        cursor:pointer;
        display:none;
 } 
 .ie{  
       _position: absolute; 
       _clear: both;  
       _top:expression(eval(document.compatMode &&  
               document.compatMode=='CSS1Compat') ?  
               documentElement.scrollTop  
               +(documentElement.clientHeight-this.clientHeight) - 1  
               : document.body.scrollTop  
               +(document.body.clientHeight-this.clientHeight) - 1);
}


ie6 ie7 ie8 ff兼容fixed的写法?

fixed只有ie6 不支持 其他浏览器都支持的 我写了个demo给你
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>fixed</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link rel="stylesheet" type="text/css" href="css/.css" />
<style>
* html,* html body{background-image:url(about:blank);background-attachment:fixed;}
.fixed{ position: fixed; right: 0; top: 50%; margin-top: -150px; width: 200px; height: 300px; border: 1px solid #ccc;}
.ie6{ _position:absolute; _margin-top: 0; _top:expression(documentElement.scrollTop+(documentElement.clientHeight-this.offsetHeight)/2)} /* ie6 fixed hack */
.hd{ height: 50px}
.bd{ height: 200px}
.ft{ height: 50px;}
.hh{ height: 2000px;}
</style>
</head>
<body>
<div class="fixed ie6">
<div class="hd">title</div>
<div class="bd">body</div>
<div class="ft">footer</div>
</div>
<div class="hh"></div>
</body>
</html>...余下全文>>
 

对于IE8对position:fixed的支持问题我在用静态html测试没问题,转换成php后在IE中失败其他浏览器正常

你echo 出来有没有html报头?不然是会有问题的.最好把你的代码贴出来.PHP的,我本地测试没有问题
 

相关内容

    暂无相关文章

评论关闭