2010-05-15 47 views
2
#fixed { 
    border:1px solid red; 
    height:100px; 
    left:50%; 
    margin-left:-500px; 
    position:fixed; 
    top:0; 
    width:1000px; 
} 

我該如何讓這個元素在IE6中以相同的方式顯示?股利是直接的第一個元素在體內 問候IE6中的CSS固定容器

回答

2

IE 6不支持position: fixedSource),並沒有簡單的CSS-唯一的解決辦法,據我所知。

您需要採用基於JavaScript的解決方案,在頁面滾動時調整元素的位置。

有一個非常簡單的解決方案概述在this SO question。這些基於JS的解決方案在我的經驗中往往會非常不穩定和不穩定,它們遠不及position: fixed的平滑性。

0

嗯,你可以試試這個CSS - 然後元素居中。

<!--[if lt IE 7]> 
<style type="text/css"> 
#fixed { 
margin: 0 auto; 
} 
</style> 
<![endif]--> 
1

抱歉沒有時間來我的樣本與您的具體要求翻譯,但靈感與代碼:

// Modern browser : FF, Chrome, Opera 
// ---------------------------------------- 

#fixmetoo { position: absolute; right: 0px; bottom: 0px; } 
div > div#fixmetoo { position: fixed; } 


// IE6 
------------------------------------------- 

<!--[if lt IE 7]> 
div#fixmetoo { 
     right: auto; bottom: auto; 
     left: expression((-80 - fixmetoo.offsetWidth + (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth) + (ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft)) + 'px'); 
     top: expression((-100 - fixmetoo.offsetHeight + (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) + (ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop)) + 'px'); 
    } 
<![endif]--> 
+0

很大,但它是相對於底部固定,而不是居中。我不太喜歡忽略這樣的事情。我需要的是中心頂部。 – Moak 2010-05-21 03:51:24