IE8中的CSS问题

时间:2013-09-09 13:54:34

标签: css

我有2个Div,一个Div应该出现在另一个Div旁边,并且它在所有浏览器中的工作方式与预期相同,但在IE8中,右侧div出现在左侧div下,同样在IE9中正常工作,但是问题是只有IE8,如何克服这一点,因为我没有太多使用Css的经验

 .leftcontent {
background: none repeat scroll 0 0 #;
float: left;
height: 500px;
width:25%;
 }


.rightcontent {
background: none repeat scroll 0 0 #;
float: left;
height: 500px;
width:80%;
 }

2 个答案:

答案 0 :(得分:1)

由于IE条件评论

,您还可以使用IE的特定css进行重载
<!--[if IE 8]> pour IE 8.0 <![endif]-->

有几种方法可以使用它们,2个例子:

  • 在标题中添加特定的CSS

  • 和/或使用ie8类初始化一个body,以便在你的css中定义:

_

.yourCssClass{
   /*common css attributes*/
}

.ie8 .yourCssClass{
  /*ie8 specific css attributes*/
}

答案 1 :(得分:0)

注意你的宽度: 25%+ 80%= 105%..这不对..

一个已知的IE 8错误是它以不同于其他浏览器的方式解析宽度。 它解析20%+ 80%+ [其他]&gt; 100%..(参见注释:可能与avrahamcool建议的内联块相关)

解决此问题的常见(也是最简单)方法是略微降低宽度 例如:

 .left_content {
background: none repeat scroll 0 0 #;
float: left;
height: 500px;
width:19%;
 }


.cal_content {
background: none repeat scroll 0 0 #;
float: left;
height: 500px;
width:79%;
 }

19%+ 79%= 98%,IE会表现出来。

相关问题