Home  >  Article  >  Web Front-end  >  When ie7 does not recognize !important [Layout solution]_Experience exchange

When ie7 does not recognize !important [Layout solution]_Experience exchange

WBOY
WBOYOriginal
2016-05-16 12:09:211608browse

在IE7之前,我們在佈局時常用!important來解決IE和FF之間的差別; 但是在IE7出來之後,!important對IE7就不起作用了,而有些時候IE7的解釋方法又與FF和IE6不同;這時新的問題就出現了;用!important可以解決IE6但是解決不了IE7; 這樣在不同的瀏覽器中看到的同一個網頁的效果就不同了;

這是前天作版面時的一個問題;可以先看一下效果;http://www.zishu.cn/blogview.asp?logID=553 

或是運行下邊的程式碼也可以同樣看到效果:

複製程式碼 程式碼如下:





zishu.cn test




  

        
  • 64d / 47 hitspixu

  •     
  • 24d / 35 hits秀才

  •     
  • 66d / 87 hits透露

  •     
  • 40d / 34 hitsLIVID

  •     
  • 47d / 56 hits老孟

  •     
  • 42d / 36hits小玉

  •     
  • 63d / 67 hitspixu

  •   





在這個例子中,如果我把
 程式碼
*+html #zishu_test li a:hover span {margin-left:-8px; }/* IE7*/ 
這行刪除;那麼在IE7中;就會有差別了;

為了解決這個問題,我看了;http://www.blueidea.com/tech/site/2006/3626.asp 裡邊的一種方法; 但是如果程式設計師和佈局人不是同一個人的話;這樣的方法很不好控制; 於是才有了下邊的方法;

以下是程式碼; 
 程式碼
複製程式碼 程式碼如下:

* html #zishu_test  a:hover ginsppanft; /* IE6 */  
*+html #zishu_test li a:hover span {margin-left:-8px; }/* IE7*/  
「*+html」被ie7與ie5.01所使用,而區分ie7與ie5.01又有很簡單的方法,便是important,把important寫在前面,這樣才能形成了單獨針對ie7 hack的方法了。

例如:

*+html div.IE7 { 
width:200px; !important; 
width:100px
};
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Solve the Flash wireframe problem after IE upgrade_Experience exchangeNext article:Solve the Flash wireframe problem after IE upgrade_Experience exchange

Related articles

See more