2014-05-06 44 views
1

我想添加即特定的CSS到CSS文件。在CSS文件IE特定的CSS

.center{ 
margin-top:-40px !important; 
} 

我嘗試添加

.ie .center{ 
    margin-top:-40px !important; 
    } 

但這種解決方案並不work.Is有沒有辦法做到這一點。

+0

你是如何加入'.ie'類的'body'? –

+0

推薦此鏈接http://stackoverflow.com/questions/11173106/apply-style-only-on-ie並試過了@Paulie_D – abinaya

+1

不回答我的問題...你如何添加'.ie'類?記住有條件的評論只有IE9及以下。 –

回答

0

在ie.css

.ie .center{ 
    margin-top:-40px !important; 
} 

如果你想針對IE瀏覽器的特定版本則例如在你的腦袋標籤

<!--[if IE]> 
<link rel="stylesheet" type="text/css" href="ie.css" class="ie" /> 
<![endif]--> 

添加這並粘貼你的CSS

<!--[if IE]> 
    <link rel="stylesheet" type="text/css" href="ie10.css" class="ie10" /> 
<![endif]--> 

和你在ie10.css中的css應該是

.ie10 .center{ 
     margin-top:-40px !important; 
} 

獲得更多的IE具體黑客herehere

1

您需要編寫HTML IF條件,檢查客戶端的瀏覽器是否爲IE

<!--[if IE]> <link rel="stylesheet" type="text/css" href="ie.css" /> <![endif]-->

只要你知道它看起來的Internet Explorer的所有版本。在任何情況下,我不建議使用這種方法,最好是所有瀏覽器的一個CSS文件。

1

使用這個。你可以在你的正常風格中使用它。不需要爲IE創建其他的css文件。

.center{ 
    margin-top:-40px; /* IE9 and below */ 
    margin-top:-40px\9; /* IE8 and below */ 
    *margin-top:-40px; /* IE7 and below */ 
    _margin-top:-40px; /* IE6 */ 
} 
+0

我需要ie ie ie10的特定css也 – abinaya

0

之前,我把我的回答,我看了看貼在其他的答案,我看到您的評論

「我需要即特定CSS的IE10也」

所以我一定現在告訴你,Conditional Comments(這就是那些IE特定的css applier被稱爲),因爲他們認爲IE10及更高版本被禁用,因爲IE10他們修復了大多數錯誤,並且不再需要它們。