2010-05-05 62 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需要,虽然不支持它的人会简单地忽略它。

相关问题