position:fixed;在IE6中的完美实现
2010-09-14 11:24
387 查看
要点:要用html5
[html]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>
<style>
body{
_background: url(about:blank) fixed;
}
.he1200{
height:1200px;
}
#fixable{
position:fixed;
width:200px;
height:30px;
border:1px solid red;
}
</style>
</head>
<body>
<div class="he1200"></div>
<div id="fixable">fixablei in ie6</div>
<script>
function fixable(d,c) {
d.style.left = c.left;
if (/msie (\d+\.\d)/i.test(navigator.userAgent) && parseFloat(RegExp["\x241"]) && parseFloat(RegExp["\x241"])<7) {
d.style.position='absolute';
d.style.setExpression("top", "eval((document.documentElement||document.body).scrollTop+" + c.top + ") + 'px'");
}else{
d.style.top = c.top+'px';
}
}
var doc = document.compatMode == "BackCompat" ? document.body : document.documentElement;
fixable(document.getElementById('fixable'),{top:doc.clientHeight-300,left:"600px"});
</script>
</body>
</html>
[/html]
另外有哥们儿修改一下,和doctype没关系了,和html5也没关系了,但一定要加上doctype
[html]</pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<style>
body {
_background: url(about:blank) fixed;
}
.he1200 {
height:1200px;
}
#fixable {
position:fixed;
left:100px;
top:300px;
_position:absolute;
_top:expression((document).documentElement.scrollTop+300);
}
</style>
</head>
<body>
<div></div>
<div id="fixable">fixablei in ie6</div>
</body>
</html>
<pre>[/html]
[html]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>
<style>
body{
_background: url(about:blank) fixed;
}
.he1200{
height:1200px;
}
#fixable{
position:fixed;
width:200px;
height:30px;
border:1px solid red;
}
</style>
</head>
<body>
<div class="he1200"></div>
<div id="fixable">fixablei in ie6</div>
<script>
function fixable(d,c) {
d.style.left = c.left;
if (/msie (\d+\.\d)/i.test(navigator.userAgent) && parseFloat(RegExp["\x241"]) && parseFloat(RegExp["\x241"])<7) {
d.style.position='absolute';
d.style.setExpression("top", "eval((document.documentElement||document.body).scrollTop+" + c.top + ") + 'px'");
}else{
d.style.top = c.top+'px';
}
}
var doc = document.compatMode == "BackCompat" ? document.body : document.documentElement;
fixable(document.getElementById('fixable'),{top:doc.clientHeight-300,left:"600px"});
</script>
</body>
</html>
[/html]
另外有哥们儿修改一下,和doctype没关系了,和html5也没关系了,但一定要加上doctype
[html]</pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<style>
body {
_background: url(about:blank) fixed;
}
.he1200 {
height:1200px;
}
#fixable {
position:fixed;
left:100px;
top:300px;
_position:absolute;
_top:expression((document).documentElement.scrollTop+300);
}
</style>
</head>
<body>
<div></div>
<div id="fixable">fixablei in ie6</div>
</body>
</html>
<pre>[/html]
相关文章推荐
- 在 IE6 中实现 position:fixed; 的办法
- 完美解决IE6不支持position:fixed的bug
- position:fixed在IE6下的实现
- 完美解决IE6不支持position:fixed
- CSS 仿position:fixed做的对联,完美兼容IE6
- IE6下实现position:fixed
- 完美解决IE6不支持position:fixed的bug
- 超完美解决ie6不支持position: fixed的bug
- 完美解决IE6不支持position:fixed的bug
- position:fixed在IE6下的实现
- ie6不识position:fixed,固定定位的其它实现
- 完美解决IE6不支持position:fixed的bug
- 完美解决IE6不支持position:fixed的bug
- 五行代码终极完美解决从IE6到Chrome所有浏览器的position:fixed;以及闪动问题
- IE6支持position:fixed最完美方案
- 在ie6下实现position-fixed的效果
- 完美解决IE6不支持position:fixed的bug
- 实现 IE6 下支持 position-fixed 的 CSS 属性并解决“振动”的问题
- 完美解决IE6不支持position:fixed的bug
- 在ie6下实现position-fixed的效果--------续集---对联效果(02)