查看: 3779|回复: 0
上一主题 下一主题

CSS Hack大全-教你如何区分出IE6-IE10、FireFox、Chrome、Opera

80572

主题

0

好友

积分

离线 发信

跳转到指定楼层
楼主
发表于 2017-03-10 21:49 | 只看该作者 | 倒序浏览

板ㄧ娴瑙E6-IE10FirefoxChromeOperaSafari伴浼澶锛惧浜楦o瀵圭ㄦ锋ヨ浜寰澶╁锛涓杩杩氨︿Web绔浜哄浜
浠澶╂涓浜甯哥ㄧCSS Hack寸浜涓涓锛父ㄧIE hack浠ュChromeOpera娴瑙ㄧHack锛骞舵杩浜CSS Hack缁煎涓璧凤浜涓涓娴瑙ㄦ璇ㄣ濡炬绀猴

涓㈠氨ョ涓涓浠gэ

htmlㄥ锛

浠g濡涓:


<div class="content">
    <div class="test"></div>
    <div class="txt">
        <p>IE6涓诧<span class="ie6" style="background-color: #ccc;">#ccc</span></p>
        <p>IE7涓诧<span class="ie7" style="background-color: #666;">#666</span></p>
        <p>IE8涓诧<span class="ie8" style="background-color: #06f;">#06f</span></p>
        <p>IE9涓诧<span class="ie9" style="background-color: #f00;">#f00</span></p>
        <p>IE10涓诧<span class="ie10" style="background-color: #0ff;">#0ff</span></p>
        <p>webkit,Safari,Chrome涓诧<span class="webkit-safari-gg" style="background-color: #ff0;">#ff0</span></p>
        <p>FireFox涓诧<span class="firefox" style="background-color: #f0f;">#f0f</span></p>
        <p>Opera涓诧<span class="opera" style="background-color: #0f0;">#0f0</span></p>
    </div>
</div>

CSSㄥ锛姝らㄥ灏卞创Hackㄥ浠gэ甯灞灏变璐翠:

浠g濡涓:


.content .test {
    width: 200px;
    height: 200px;
    background: #f60; /*all*/
    background: #06f9; /*IE*/
    *background: #666; /*IE6,7*/
    _background: #ccc; /*IE6*/
}

/* webkit and opera */
@media all and (min-width:0){
    .content .test {
        background: #0f0;
    }
}

/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    .content .test {
        background: #ff0;
    }
}

/*FireFox*/
@-moz-document url-prefix() {
    .content .test {
        background: #f0f;
    }
}

/*IE9+*/
@media all and (min-width:0) {
    .content .test{
        background: #f009;
        }
}

/*IE10+*/
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .content .test {
        background: #0ff;
    }
}

css-hack-ms-moz-webkit-o-Jb51.net.rar

来源:http://www.jb51.net/article/50116.htm