2010-05-05 56 views
2

我有一個問題,即在ie中顯示設置高度。在IE中的高度顯示不同於Firefox的

在我的CSS中,我已經設置了我的側邊欄div的高度爲2150px;它在Firefox中顯示得很好,但在ie中不顯示全高。

我怎樣才能得到ie顯示我在ie中設置的高度?

在此先感謝

源代碼如下

#sidebar_newspr{ 
width:160px; 
min-height:2150px; 
margin-top:1px; margin-right:2px; 
border-right-style:solid; border-right-color:#900; border-right-width:1px; 
float:left; 
} 
#sidebar_newspr a{ 
text-decoration:none; 
color:#FFF; 
font-size:12px; font-family:Verdana,Arial,Helvetica,sans-serif; 
} 
#sidebar_newspr a:hover{ 
color:#900; 
} 

回答

2

這有點在黑暗中拍攝的,因爲你沒有真正說明你在測試它其中的IE版本但是,min-height要求IE7和IE8在標準模式下運行。要啓用標準模式,您需要使用嚴格的!DOCTYPE

the documentation

的Internet Explorer 7,所述最小高度/最大高度屬性適用於浮動和絕對定位塊,內聯塊的元件,並且一些固有的控制。它們不適用於非替換內聯元素,例如表列和行/列組。 (「替換」元素具有固有尺寸,例如img或textArea。)

Internet Explorer 7,此屬性僅在strict!DOCTYPE下啓用。

在IE6 min-height僅適用於thtdtr元件。

+1

在IE6中,高度就像最小高度一樣。 – 2010-05-05 12:51:49

0

嘗試使用條件註釋:

<!--[if lt IE 9]> //will target IE less than version 9 
     <link href="/directroy/IE.css" rel="Stylesheet" type="text/css"/> 
<![endif]--> 

要你的頭標記和使用這個新的樣式表來定義你想要IE做什麼。

#sidebar_newspr{ 
width:160px; 
height:2150px; /*change to just height*/ 
margin-top:1px; margin-right:2px; 
border-right-style:solid; border-right-color:#900; border-right-width:1px; 
float:left; 
} 

您還可以使用多個條件註釋來定位不同版本的IE。

像這樣:

<!--[if IE 8]> //will target only IE 8 
     <link href="/directroy/IE.css" rel="Stylesheet" type="text/css"/> 
<![endif]--> 

然後嘗試你的doctype設置爲嚴格:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

可能會奏效,如果不是那麼我敢肯定,別人有另外一種想法:)

0

一些版本的IE不喜歡min-height,我儘量避免它,如果可能的話。

作爲一個快速的解決方案,不會衡量你的頁面向下像一個IE瀏覽器只風格,簡單地說明height:2150px; min-height:2150px;瀏覽器支持min-height需要,雖然不支持它的人會簡單地忽略它。

相關問題