2011-08-09 27 views
2
<!--[if IE]> 
    <style type="text/css"> 
     #botonHome .contButton p a span{ height:25px; } 
     #botonHome .contButton p a span input{ position: relative; bottom:5px; } 
    </style> 
<![endif]--> 

<!--[if IE 6]> 
    <style type="text/css"> 
     #botonHome .contButton p a span input{ display: inline; margin:0px; padding:0px; bottom:0px; height:20px; }          
    </style> 
<![endif]--> 

最后,我能够正常显示所有浏览器中的按钮,但我不想在我的html文件中使用此内联代码。我怎样才能解决这个不同的CSS实现IE只使用CSS。这个IE和IE6破解只有CSS?

回答

3

诱骗IE6只是把 “_” 任何属性之前,例如

#botonHome .contButton p a span input{ _display: inline; _margin:0px; _padding:0px; _bottom:0px; _height:20px; } 

UPDATE:

请点击此链接为css IE hacks

+0

是的,但不会IE7也解释这些句子? –

+0

我已经更新了我的答案。请按照链接,你会发现所有你需要的关于这个话题,包括详细的回答你的问题 – mkk

+0

链接帮助,欢呼队友! –

1

这些条件注释是IE的解决方法非常方便。我会使用它们,但不包括样式元素,而是包含一个css文件。这样,您不必将整个样式添加到每个页面,并且您可以更轻松地添加其他调整。

3

对于IE 6使用每个样式之前_下划线符号,对于IE 7使用每个样式之前*星符号,并且对于IE8 & IE9与;分号符号闭合样式之前使用\0/。请参阅下面的代码。

#botonHome .contButton p a span input { 

    /*For IE 6*/ 
    _display: inline; 
    _margin:0px; 
    _padding:0px; 
    _bottom:0px; 
    _height:20px; 

    /*For IE 7*/ 

    *display: inline; 
    *margin:0px; 
    *padding:0px; 
    *bottom:0px; 
    *height:20px; 

    /*For IE 8 & 9*/ 

    display: inline\0/; 
    margin:0px\0/; 
    padding:0px\0/; 
    bottom:0px\0/; 
    height:20px\0/; 
} 
+0

缺点是你的CSS不会验证,可能会引入未来的问题,而有条件的评论,你确定你的黑客只包含在需要它们的浏览器中。 – GolezTrol