[英]css conditional formatting
我有以下代碼來檢查用戶是否使用IE7 ......它需要超越.web_info樣式。 如果不是IE7它使用默認樣式,如果它不是IE,它將使用ff_styles.css。 這似乎不起作用。
<link rel="stylesheet" type="text/css" href="../styles.css">
<![if !IE]>
<link rel="stylesheet" type="text/css" href="../ff_styles.css">
<![endif]>
<![if IE 7]>
<style type="text/css">
.web_info
{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]>
有什么建議么? 謝謝
不應該這樣
<!--[if IE 7]>
..
<![endif]-->
和
<!--[if !IE]>
...
<![endif]-->
注意
<!--[if !IE]>
永遠不應該產生真實,因為這些條件評論只能由IE解釋。
條件注釋是IE特定的,因此“ <![if !IE]>
”不是firefox或任何其他瀏覽器的有效指令。 另外我建議你嘗試以下語法:
<!--[if IE 7]>
<style type="text/css">
.web_info
{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]-->
關於我的最后一個注意事項:由於IE7 / IE8主要是標准兼容的,如果可能的話,應該避免這些CSS黑客攻擊。
更新:感謝slosd我站得更正了! 根據“ 使用條件注釋支持IE ”,您可以使用以下內容隱藏IE中的內容:
<!--[if !IE]>-->
do something; IE will ignore this, other browsers parse it
<!--<![endif]-->
很抱歉給我帶來的不便!
完整的工作示例:
<link rel="stylesheet" type="text/css" href="../styles.css">
<!--[if !IE]>-->
<link rel="stylesheet" type="text/css" href="../ff_styles.css">
<!--<![endif]-->
<!--[if IE 7]>
<style type="text/css">
.web_info{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]-->
不要檢查瀏覽器是否不是IE,檢查它是否是IE7然后是否是IE,然后默認為回退。 更多信息: http : //www.quirksmode.org/css/condcom.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.