CSS中兼容性IE,Chrome,Firefox和CSS Hack

作者:袖梨 2022-06-25

hack列表(全部经笔者测试,均为标准模式下,混杂模式由于很少会用到所以未对其进行测试):

 

word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">点击查看原图

其中粉红色部分为属性hack,黄色部分为选择器hack,它们可以结合使用。此外Firefox和Chrome也有它们专有的hack,详细hack方式及使

用示例如下:

Firefox:

@-moz-document url-prefix()    /*写在选择器外层时(只可写在此处):Firefox only*/

Chrome:

@media screen and (-webkit-min-device-pixel-ratio:0)    /*写在选择器外层时(只可写在此处):Chrome only*/

使用示例-写在选择器前面:

 

 

@-moz-document url-prefix()    /*Firefox*/

{

        body

        {

                background-color:pink;

        }

}

注意事项:

浏览器对css的解析是从前到后的,并且采用最后一个样式声明。

 还是不知道怎么区分.好吧,来看个例子:





区别IE6、IE7、IE8、FireFox的CSS hack -<span class="Apple-converted-space"> </span>http://www.111com.net%3c/title><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> <style type="text/css"><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> <!--<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> #test,#note{<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     margin:0 auto;<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     text-align:center;   <span class="Apple-converted-space"> </span><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> }<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> #test {<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     border: 1px solid #000000;<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     color:#fff;<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     line-<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> }<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> .color{<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     background-color: #CC00FF;        /*所有浏览器都会显示为紫色*/<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     background-color: #FF00009;    /*IE6、IE7、IE8会显示红色*/<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     *background-color: #0066FF;        /*IE6、IE7会变为蓝色*/           <span class="Apple-converted-space"> </span><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     _background-color: #009933;        /*IE6会变为绿色*/<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> }<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> --><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> </style><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> </head></p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-"><body><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> <div id="test" class="color">测试方块<span class="Apple-converted-space"> </span>www.mycsu.net<span class="Apple-converted-space"> </span></div></p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-"><div id="note"><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <strong style="color:#009933">IE6</strong><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <strong style="color:#0066FF">IE7</strong><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <strong style="color:#FF0000">IE8</strong><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" />     <strong style="color:#CC00FF">FireFox</strong><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> </div><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> </body><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> </html></p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">---------------------------------------------------------------------------------------------------</p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">background: red;       /* 对FF Opera和Safari有效 */<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> #background: blue;      /* 对 IE6 和 IE7有效 */<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> _background: green;      /* 只对IE6有效 */<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> /*/background: orange;*/      /** 只对IE8有效 **/</p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">!important         /*FF、IE7有效*/</p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">*         /*IE都有效*/</p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">============================================================</p> <p style="padding-bottom: 0px; text-transform: none; background-color: #ffffff; text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/20px 微软雅黑; white-space: normal; letter-spacing: normal; color: #000000; word-spacing: 0px; padding-top: 0px; -webkit-text-stroke-">IE8是可以和IE7兼容的,简单一行代码,让IE8自动调用IE7的渲染模式<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> 只需要在页面中加入如下HTTP meta-tag:<br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /><br style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px" /> 只要IE8读到这个标签,它就会自动启动IE7兼容模式,保证页面完整展示。</p> </span></strong></p></td> </tr> </table> </div> </div> </section> <section class="wrap-box"> <div class="g-tit"> <h2>相关文章</h2> </div> <ul class="s-list nobord notop"> <li> <a href="/art-424547.htm" class="s-card"> <div class="s-card-l"> <p class="tit">绝区零月城柳意像影画怎么样</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e6ca03ddc51.jpeg" alt="绝区零月城柳意像影画怎么样" /> </div> </a> </li> <li> <a href="/art-424546.htm" class="s-card"> <div class="s-card-l"> <p class="tit">无限暖暖翩翩愿飞去怎么样</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e6c9d9ff471.jpeg" alt="无限暖暖翩翩愿飞去怎么样" /> </div> </a> </li> <li> <a href="/art-424545.htm" class="s-card"> <div class="s-card-l"> <p class="tit">黑神话悟空1.0.12.16581版本更新公告</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e507ca071a1.jpeg" alt="黑神话悟空1.0.12.16581版本更新公告" /> </div> </a> </li> <li> <a href="/art-424544.htm" class="s-card"> <div class="s-card-l"> <p class="tit">光遇12.27红石碎片在哪里</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e507ba9f881.jpeg" alt="光遇12.27红石碎片在哪里" /> </div> </a> </li> <li> <a href="/art-424543.htm" class="s-card"> <div class="s-card-l"> <p class="tit">无限暖暖翩翩愿飞去怎么样 无限暖暖翩翩愿飞去能力套装介绍</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e4a26e5fbf1.jpeg" alt="无限暖暖翩翩愿飞去怎么样 无限暖暖翩翩愿飞去能力套装介绍" /> </div> </a> </li> <li> <a href="/art-424541.htm" class="s-card"> <div class="s-card-l"> <p class="tit">无限暖暖流星绚烂时怎么样 无限暖暖流星绚烂时套装介绍</p> <div class="info"> <span class="person">游戏攻略</span> <span class="time">2024-12-27</span> </div> </div> <div class="s-card-pic"> <img src="/images/lazy.gif" data-src="/uploads/20241227/logo_676e4a2502a0a1.jpeg" alt="无限暖暖流星绚烂时怎么样 无限暖暖流星绚烂时套装介绍" /> </div> </a> </li> </ul> </section> <section class="wrap-box"> <div class="g-tit"> <h2>精彩推荐</h2> </div> <ul class="card-box"> <li class="card3"> <a href="/app/101735.htm" target="_self" class="figure"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e0450ce2d81.png" alt="王牌战争 安卓最新版本v16.4" /> </div> <p class="figure-head">王牌战争 安卓最新版本v16.4</p> <span class="figure-btn">下载</span> </a> </li> <li class="card3"> <a href="/app/101700.htm" target="_self" class="figure"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e03a61e99d1.png" alt="火柴人联盟2360版 安卓版v1.9.5" /> </div> <p class="figure-head">火柴人联盟2360版 安卓版v1.9.5</p> <span class="figure-btn">下载</span> </a> </li> <li class="card3"> <a href="/app/101695.htm" target="_self" class="figure"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e0396ebfd41.jpg" alt="奥特曼之格斗超人体验版 安卓最新版v9.1.0" /> </div> <p class="figure-head">奥特曼之格斗超人体验版 安卓最新版v9.1.0</p> <span class="figure-btn">下载</span> </a> </li> <li class="card3"> <a href="/app/101670.htm" target="_self" class="figure"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e033a685a71.png" alt="忍者新世代测试服 官方版v3.72.50" /> </div> <p class="figure-head">忍者新世代测试服 官方版v3.72.50</p> <span class="figure-btn">下载</span> </a> </li> </ul> <ul class="card-box-b"> <li class="card10"> <a href="/app/101736.htm" target="_self" class="figure2"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e0458633a91.png" alt="创造与魔法 安卓版v1.0.0750" /> </div> <div class="figure-cont"> <p class="figure-head">创造与魔法 安卓版v1.0.0750</p> <div class="figure-desc"> <span>模拟经营</span> <span>创造与魔法 安卓版v1.0.0750</span> </div> <div class="figure-desc"> <p>创造与魔法是一款开放世界手游,在游戏中玩家可探索这个奇妙的世</p> </div> </div> <span class="figure-btn">下载</span> </a> </li> <li class="card10"> <a href="/app/101730.htm" target="_self" class="figure2"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e044161c9d1.jpg" alt="创造与魔法修改版 最新版v1.0.0750" /> </div> <div class="figure-cont"> <p class="figure-head">创造与魔法修改版 最新版v1.0.0750</p> <div class="figure-desc"> <span>模拟经营</span> <span>创造与魔法修改版 最新版v1.0.0750</span> </div> <div class="figure-desc"> <p>创造与魔法无限点券版是款探索冒险游戏,该款游戏的操作还是蛮自</p> </div> </div> <span class="figure-btn">下载</span> </a> </li> <li class="card10"> <a href="/app/101729.htm" target="_self" class="figure2"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e043ca53f71.png" alt="战争与文明官方版本 安卓版v1.7.16" /> </div> <div class="figure-cont"> <p class="figure-head">战争与文明官方版本 安卓版v1.7.16</p> <div class="figure-desc"> <span>模拟经营</span> <span>战争与文明官方版本 安卓版v1.7.16</span> </div> <div class="figure-desc"> <p>战争与文明是一款由上海邮通科技有限公司开发的战争策略游戏,这</p> </div> </div> <span class="figure-btn">下载</span> </a> </li> <li class="card10"> <a href="/app/101722.htm" target="_self" class="figure2"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e042036f3c1.png" alt="迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0" /> </div> <div class="figure-cont"> <p class="figure-head">迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0</p> <div class="figure-desc"> <span>模拟经营</span> <span>迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0</span> </div> <div class="figure-desc"> <p>迷你世界0元购买皮肤版是这款开放沙盒冒险建造游戏的特殊破解版</p> </div> </div> <span class="figure-btn">下载</span> </a> </li> <li class="card10"> <a href="/app/101718.htm" target="_self" class="figure2"> <div class="figure-box"> <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20241227/logo_676e041326a061.jpg" alt="创造与魔法无限经验版 安卓版v1.0.0750" /> </div> <div class="figure-cont"> <p class="figure-head">创造与魔法无限经验版 安卓版v1.0.0750</p> <div class="figure-desc"> <span>模拟经营</span> <span>创造与魔法无限经验版 安卓版v1.0.0750</span> </div> <div class="figure-desc"> <p>创造与魔法无限经验版是款可以改造环境,整个游戏的自由度还是蛮</p> </div> </div> <span class="figure-btn">下载</span> </a> </li> </ul> </section> <footer class="foot"> <a href="/" class="logo-icon"> <img src="/mobile/images/logo2.png" alt="一聚教程网"> </a> <p>Copyright © 2010-2022</p> <p>111cn.net All Rights Reserved</p> </footer> <script> var advData = {"img_fixed_pc_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e9729f58.jpg","img_fixed_mob_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e8793225.jpg","url_adv":"http:\/\/shop.hushen.cn\/shop\/c\/baojianpin.html","str_adv":"\u864e\u795e\u5546\u57ce\uff1a\u5173\u7231\u7537\u6027\uff0c\u66f4\u61c2\u7537\u4eba\u3002\u89e3\u51b3\u5927\u4f17\u7684\u7537\u8a00\u4e4b\u9690","img_popup_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e748238d.png","pc_show_img":"2","pc_show_popup":"2","pc_show_video":"2","mob_show_img":"2","mob_show_popup":"2","mob_show_video":"2","close_adv":"https:\/\/img.111cn.net\/uploads\/20240508\/663b20650801e.png","video_adv":"\/pc\/images\/pc-adv.mp4"}; </script> <script src="/jspc/funcmob.js" type="text/javascript"></script> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-DSRRGRV1TL"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-DSRRGRV1TL'); </script> <div class="back-top" style="display: block;"> <span class="icon-box"> <svg class="icon" viewBox="0 0 1024 1024"> <path d="M213.333333 640h170.666667v256h256v-256h170.666667l-298.666667-341.333333zM170.666667 128h682.666666v85.333333H170.666667z" fill="#0374f3"></path> </svg> </span> </div> </div> <script src="/js/stat.js"></script> </body> </html>