都是IE惹的禍多瀏覽器安全色問題_經驗交流

來源:互聯網
上載者:User
IE7發布已經有些日子了,因此網站需要照顧的瀏覽器又多了一個。這兩天設計師們在做相容,找到了一個解決辦法,這裡既是共用,也是記錄。結合之前自己使用important!和/**/來區分IE5、IE6、Moz的經曆,以下代碼區分4個瀏覽器,複製代碼儲存成一個HTML檔案看看效果吧:(
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> <style type="text/css"> <!-- #example { position: absolute; top: 50%; left: 50%; width: 200px; height: 150px; margin-top: -75px; margin-left: -100px; } #example div { padding: 20px; text-weight: bold; font: 11px/150% Verdana, Arial, Helvetica, sans-serif; text-align: right; } #example { background: red; /*For Moz*/ } * html #example { background: yellow; /*For IE5*/ background/**/: green; /*For IE6*/ } *+html #example { background: blue; /*For IE7*/ } --> </style> </head> <body> IE5: YELLOW IE6: GREEN IE7: BLUE MOZ: RED </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
特別提醒:
#example {
background: red; /*For Moz*/
}
* html #example {
background: yellow; /*For IE5*/
background/**/: green; /*For IE6*/
}
*+html #example {
background: blue; /*For IE7*/
}
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.