[英]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.