您的位置:首页 > 其它

position:fixed; IE6下解决办法。。

2012-02-11 16:19 344 查看
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
* { margin:0; padding:0; }
html { background:url(about:blank) fixed; }
body { height:2000px; }
.box { width:100px; height:80px; background:#3cf; position:fixed; _position:absolute; _top:expression(offsetParent.scrollTop + 10); top:10px; right:20px; }
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>


一、html { background:url(about:blank) fixed; }  解决ie6下,下拉滚动条有抖动现象。
  about:blank 可以是任何并不存在的文件,如:url(123);

二、top:expression(offsetParent.scrollTop + 10)  如果是距离头部0px的话,那么应该top:expression(offsetParent.scrollTop)
top: expression(offsetParent.scrollTop + offsetParent.clientHeight-offsetHeight) 如果是想要层在网页底部的话用这个。



其他方法:

<!DOCTYPE HTML>
<html>
<head>
<title>fixbox</title>
<meta charset="utf-8">
<style>
html,body{
height: 100%;
overflow: hidden;
margin: 0;
}
.m-window{
background-color: #add8e6;
height: 100%;
overflow: auto;
}
.fixbox {
position: absolute;
width: 100px;
height: 100px;
bottom: 0;
right: 15px;
background-color: #00bfff;
}
</style>
</head>
<body>
<div class="m-window">
<div class="fixbox"></div>
<div class="m-body" style="height: 10000px">虚拟的body</div>
</div>
</body>
</html>


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: