2013-05-08 26 views
1

這裏是我的CSS:針對CSS中的IE8(少)?

.lt-ie8{ 
    body{ 
     display:none!important; 
    } 
} 

這裏是我的HTML:

<!--[if lt IE 7]>  <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 
<!--[if IE 7]>   <html class="no-js lt-ie9 lt-ie8"> <![endif]--> 
<!--[if IE 8]>   <html class="no-js lt-ie9"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> 
<head> 

的CSS似乎並不正確目標IE7,沒有人知道我要去哪裏錯了嗎?

+0

'none'和'important'之間需要一個空格 – 2013-05-08 16:37:20

+0

仍然無效。 – beans 2013-05-08 16:41:32

+1

你的問題很混亂 - 你是針對IE8還是IE7? – BoltClock 2013-05-08 16:52:57

回答

1

這對我來說非常合適。

<html> 
<head> 
    <title></title> 
    <style type="text/css"> 
     .test{ 
      background: green; 
      height: 100px; 
      width: 100px; 
     } 
    </style> 
    <!--[if lt IE 7]>  <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 
    <!--[if IE 7]>   <html class="no-js lt-ie9 lt-ie8"> 
     <style type='text/css'> 
      .test{ 
       background: red; 
      } 
     </style> 
    <![endif]--> 
    <!--[if IE 8]>   <html class="no-js lt-ie9"> <![endif]--> 
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> 

</head> 
<body> 
    <div class="test"></div> 
</body> 
</html> 
+0

仍然無法使用。 – beans 2013-05-08 16:40:32

+0

您是否檢查過[IE開發人員工具欄](http://www.microsoft.com/en-in/download/details.aspx?id=18359)上的條件css是否正在應用? – 2013-05-08 16:44:19

+0

是的,我有..... – beans 2013-05-08 16:45:02

0

IE7不會讓你隱藏body標籤。解決辦法是創建一個包裝div並隱藏它。我以前遇到過這個,但我不確定原因。

<html> 
<!--[if IE 7]>   <html class="no-js lt-ie9 lt-ie8"> <![endif]--> 
<!--[if IE 8]>   <html class="no-js lt-ie9"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> 
<head> 
    <style> 
     .lt-ie8 div{ display: none !important;} 
     body, html{width: 100%; height: 100%;} 
     div {background-color: red; width: 100%; height: 100%;} 
    </style> 
</head> 
<body> 
<div></div> 
</body> 
</html>