DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS進階教程
IE8 與舊版 IE 的 CSS Hack 整理
編輯:CSS進階教程     

舊版 IE 的 CSS hack 雖然不優雅,卻常是維護歷史網站時的必要手段。以下整理常見的顏色覆寫順序,方便日後快速查閱。

#box {
  color: red;
  color: red !important;
  _color: red;
  *color: red;
  *+color: red;
  color: red\9;
  color: red\0;
}

大致對應

  • 一般規則:所有瀏覽器可讀。
  • !important:Firefox 與 IE7 可受影響。
  • _color:主要給 IE6。
  • *color:IE6 與 IE7 可辨識。
  • *+color:常用於 IE7。
  • \9:IE6、IE7、IE8 可辨識。
  • \0:常用於 IE8。

這些寫法在現代專案中應避免大量使用。若必須支援舊版瀏覽器,建議把 hack 集中在單一檔案或區塊,並在註解中標明用途,方便日後移除。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved