簡體   English   中英

位置已修復且Internet Explorer

[英]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調整才能使其適用於您的代碼。 我正在研究“偏移”值作為我們所說的選項。

  1. IE pre 8的版本不支持正確修復位置。
  2. 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>
您已將其標記為HTML,但“`不是HTML元素。 Internet Explorer不會讓您設置它無法識別的元素的樣式。 - 僅在HTML文檔中使用[HTML元素] [1] 您已更新了問題,因此看起來您正在使用ID選擇器而不是類型選擇器。 這使我的原始評論無關緊要。

IE 6不支持position: fixed

其他版本的IE不支持position: fixed在怪異模式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM