推薦!很全的CSS Hack速查表

來源:互聯網
上載者:User

hack速查表

建議:以標準瀏覽器為準書寫代碼,如遇到相容問題,嘗試其他方法解決問題,在萬不得已怕情況下,採用HACK解決。

以下是總結的HACK書寫方法:

瀏覽器:僅限IE6+,FF,safari,chrome,opera;(截止到2011.10.12非IE均為最新版本)。

測試環境:windows系統;

DOCTYPE:線上瀏覽效果:http://bbs.websjy.com/club/websjy_index/59/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>hack速查表</title><style type="text/css">/*reset*/* { margin:0; padding:0; }body { font:normal 12px/2 Tahoma, Arial, "\5b8b\4f53", Helvetica, sans-serif; height:100%; text-align:center; background:#fff; }h1, h2, h3, h4, h5, h6 { font-size:100%; font-weight:normal; }/* Tables still need 'cellspacing="0"' in the markup. */table { border-collapse:collapse; border-spacing:0; }ul, ol { list-style:none; }em { font-style:normal; color:#f00; }h1 { font-size:2em; font-weight:700; }.hack { width:1000px; margin:0 auto; text-align:left; }.hack table { width:100%; margin:10px 0;  }.hack td, .hack th { height:30px; padding:0 5px; border:1px solid #ccc; }.hack th { color:#cc0bf6; }.hack th.eq, .hack td.eq { width:350px; color:#333; }.hack th.identifier, .hack td.hack-data { width:350px; color:#61602f; }.hack td.no { color:#fff; text-align:center;background-color:red; }.hack td.yes { color:#fff; text-align:center;background-color:green; }.hack p b { color:green; }.hack p b.red { color:red; }.hack h2 { margin:10px 0 0 0; font-size:1.5em; font-weight:700; }.hack-list { margin:10px 0; }.hack-list li { margin-bottom:5px;zoom:1; }.hack-list span { float:left; width:15px; font-family:"\5b8b\4f53"; }.hack-list-inf { padding:0 0 0 15px;}.hack-list em { display:inline-block; margin:0 5px; }</style></head><body><h1>hack速查表</h1><div class="hack">  <p>建議:以標準瀏覽器為準書寫代碼,如遇到相容問題,嘗試其他方法解決問題,在萬不得已怕情況下,採用HACK解決。</p>  <p>以下是我總結的HACK書寫方法:</p>  <p>瀏覽器:僅限IE6+,FF,safari,chrome,opera;(截止到2011.10.12非IE均為最新版本)。</p>  <p>測試環境:windows系統;</p>  <p>DOCTYPE:<!doctype html>.</p>  <table cellpadding="0">    <thead>      <tr>        <th class="identifier">標誌符</th>        <th class="eq">樣本</th>        <th>IE6</th>        <th>IE7</th>        <th>IE8</th>        <th>IE9</th>        <th>FF</th>        <th>OP</th>        <th>SA</th>        <th>CH</th>      </tr>    </thead>    <tbody>      <tr>        <td class="hack-data">*</td>        <td>.eq {*color:#000;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">_</td>        <td>.eq {_color:#000;}</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">+</td>        <td>.eq {+color:#000;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">-</td>        <td>.eq {-color:#000;}</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">></td>        <td>.eq {>color:#000;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">\0</td>        <td>.eq {color:#000\0;}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">\9</td>        <td>.eq {color:#000\9;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">\9\0</td>        <td>.eq {color:#000\0;}</td>        <td class="no">N</td>        <td class="no">N</td>        <td>N\Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">:root .xx{xxx:xxx\9;}</td>        <td>:root .eq {color:#a00\9;}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">*+</td>        <td>.eq {*+color:#000;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">*-</td>        <td>.eq {*-color:#000;}</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">*html</td>        <td><span class="hack-data">*html</span> .eq {color:#000;}</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">*+html</td>        <td><span class="hack-data">*+html</span> .eq {color:#000;}</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">html*</td>        <td>html* .eq {color:#000;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">[;</td>        <td>.eq {color:red;[;color:blue;}</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">html>body</td>        <td>html>body .eq {color:blue;}</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">html>/**/body</td>        <td>html>/**/body .eq {color:blue;}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">html/**/>body</td>        <td>html/**/>body .eq {color:blue;}</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">@media all and (min-width:0px){}</td>        <td><span class="hack-data">@media all and (min-width:0px){.eq {color:#000;}}</span></td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">*:first-child+html</td>        <td>*:first-child+html .eq {color:blue;}</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">*:first-child+html{} *html</td>        <td>*:first-child+html{} *html .eq {color:blue;}</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">@-moz-document url-prefix(){}</td>        <td>@-moz-document url-prefix(){ .eq {color:blue;}}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">@media screen and (-webkit-min-device-pixel-ratio:0){}</td>        <td>@media screen and (-webkit-min-device-pixel-ratio:0){.eq {color:blue;}}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>      <tr>        <td class="hack-data">@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){}</td>        <td><span class="hack-data">@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){.eq {color:blue;}}</span></td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="no">N</td>        <td class="no">N</td>      </tr>      <tr>        <td class="hack-data">body:nth-of-type(1)</td>        <td>body:nth-of-type(1) .eq {color:blue;}</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="no">N</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>        <td class="yes">Y</td>      </tr>    </tbody>  </table>  <p>FF:firefox; OP:opera; SA:safari; CH:chrome; <b>Y</b>代表支援,<b class="red">N</b>代表不支援。</p>  <h2>注意事項:</h2>  <ul class="hack-list">    <li><span>·</span><div class="hack-list-inf">由於各瀏覽器更新神速,所以有些HACK可能會有變化,所以請大家注意。</div></li>    <li><span>·</span><div class="hack-list-inf"><em>[;</em>此種方式會影響後續樣式,不可取。</div>  </li>    <li><span>·</span><div class="hack-list-inf"><em>\9\0</em>並非對所有屬性都能區分IE8和IE9.比如:background-color可以,但background不可以,還有border也不可以。所以在實際用時要測試下。</div>  </li>    <li><span>·</span><div class="hack-list-inf">當同時出現<em>\0</em>;<em>*</em>;<em>_</em>;時,推薦將\0寫在*和_前面。例如:color:red\0;*color:blue;_color:green;可行,否則IE7和IE6裡的效果會失效。但border例外,放在前後都可以。保險起見,還是放在前面。 </div> </li>  </ul>  <h2>推薦寫法:</h2>  <h3>demo:</h3>  <pre>        .eq {             color:#f00;/*標準瀏覽器*/             color:#f30\0;/*IE8,IE9,opera*/             *color:#c00;/*IE7及IE6*/             _color:#600;/*IE6專屬*/            }        :root .eq {color:#a00\9;}/*IE9專屬*/        @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){.eq {color:#450;}}/*opera專屬*/        @media screen and (-webkit-min-device-pixel-ratio:0){.eq {color:#879;}}/*webkit專屬*/        @-moz-document url-prefix(){ .eq {color:#4dd;}}/*firefox專屬*/  </pre></div></body>

  

  

相關文章

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.