2011-09-30 59 views
4

,所有的瀏覽器IE7包括顯示我的底欄正確固定,所有的時間。IE8固定位置的頂部和底部調整大小錯誤

.bottom-fixed { 
    position: fixed; 
    bottom: 0; 
    margin-left: -235px; 
    min-width: 1160px; 
    max-width: 130em; 
    width: 100%; 
} 

但是在IE8中有些奇怪的東西。如果調整在底部(你可以改變的同時一個窗口的寬度和高度的方式)的右上角的幫助瀏覽器窗口的高度,一切都很好。

但是如果調整窗口的高度grapping瀏覽器窗口的頂部或底部,酒吧/ DIV停留在位置像它會當位置是絕對的,而不是位置:固定的。

任何想法如何解決這個問題?

(使用文檔類型爲HTML5)

回答

1

我不能修復與此thread Umer mentioned父浮動解。修復了所有當窗口被調整的時間:

所以我與位置應用一個簡單的JavaScript腳本固定它。

HTML

<!--[if IE 8 ]> 
    <script type="text/javascript"> 
     $(window).resize(function() { 
      ApplyPositionFixed(); 
     }); 
    </script> 
    <![endif]--> 

的Javascript

function ApplyPositionFixed() { 
    // Check if element exists 
    if ($("#bottom-bar-content").length) { 
     $(".bottom-fixed").attr('style', 'position: fixed;'); 
     console.log("Window resized"); 
    } 
    else { 
     console.info("No element changes on Window resize"); 
    } 
} 

不過。我準備好更好的解決方案。

0

還有另一種解決方案:父元素上設置height明確。例如height: 1%height: 100%

0

有同樣的問題,但在我的情況下,修復是父有position: relative。一旦我刪除了這個問題,這個問題就消失了。

0

對於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> 

而其 那些在第一線非常非常重要。

+0

好,因爲寫的,我已經使用HTML5的doctype。所以看起來並非如此。 –

相關問題