[英]Position fixed and Internet Explorer
这是我的CSS。 它在Firefox中工作正常,但在IE中无法正常工作。
#Createinner {
position: fixed;
width: 400px;
height: 280px;
margin-left: -200px;
margin-top: -140px;
top: 50%;
left: 50%;
background-color: #ccc;
}
怎么解决这个问题。
提前致谢
只需在页面顶部添加DocType标签即可
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
用IE排序我的问题是代码:
http://annevankesteren.nl/test/examples/ie/position-fixed.html
基本上补充:
h1{
position:fixed;
_position:absolute;
top:0;
_top:expression(eval(document.body.scrollTop));
}
对于IE 8中的固定位置, DOCTYPE非常重要。
之一:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
要么
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
要么
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
要么
<!DOCTYPE HTML>
而且非常重要
CSS:
#footer
{position: fixed; right: 0px; bottom: 0px; }
HTML:
<div id="footer" >
Fixed Div
</div>
IE6不支持固定位置。
如果您确实需要在IE6中使用它,请使用条件注释来提供仅IE的CSS文件和假position:fixed
使用CSS表达式position:fixed
。
(编辑以更正IE版本信息。)
我最近写了一个jQuery插件来获取位置:修复了IE 6+的工作。 它不会在滚动上抖动,它会查看功能(不是用户代理),适用于Internet Explorer 6,7,8。
如果你在IE7 +位置使用严格模式:固定将被尊重,但默认情况下IE7 +在Quirks模式下运行。 这个插件检查浏览器功能,如果它不支持position:fixed,那么它实现了jQuery修复。
http://code.google.com/p/fixedposition/
这样的事可能适合你:
$(document).ready(function(){
$("#Createinner").fixedPosition({
debug: true,
fixedTo: "bottom"
});
});
您可能需要进行一些小的CSS调整才能使其适用于您的代码。 我正在研究“偏移”值作为我们所说的选项。
http://ieproblems.blogspot.com/使用这个它将解决您的问题
#mainDiv{
overflow:auto;
}
#subDiv{
position:relative;
top:expression(this.offsetParent.scrollTop+'px');
left:expression(this.offsetParent.scrollTop+'px');
}
<html>
<head>
</head>
<body>
<div id="mainDiv">
<div id="subDiv">
This Text is Fixed
</div>
</div>
</body>
</html>
IE 6不支持position: fixed
其他版本的IE不支持position: fixed
在怪异模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.