纯CSS兼容ie6的fixed

方法一:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ie6 fixed</title>
<style type="text/css">
*{margin:0;padding:0;}
html{height:100%;overflow:hidden;}
body{height:100%;overflow:auto;}
.main{height:2000px; width:960px; background:#CCC; margin:auto;}
.gotop{position:fixed; bottom:10px; left:50%; margin-left:480px; _position:absolute; _bottom:9px; }
.gotop a{width:28px;height:22px;display:block;background:url(http://img.baidu.com/img/baike/sidebar2.gif) no-repeat 1px -104px;}
</style>
</head>
<body>

<div class="main"></div>

<div id="gotop" class="gotop">
	<a href="#" title=""></a>
</div>

</body>
</html>
  

方法二:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
*{margin:0}
body{height:1000px;width:1000px; 
    _background: url(about:blank) fixed; /* ie6 不闪屏 */
}
#fixed{width:300px;height:100px;background:red;position:fixed;right:0;top:300px;
    _position:absolute;_top:expression(eval(document.documentElement.scrollTop+300)); /* 兼容ie6*/
}
</style>

</head>
<body>
<div id="wp">
	<div id='fixed'>test</div>
</div>
</body>
</html>
 

 

你可能感兴趣的:(html,css,XHTML)