2011-08-09 32 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