当前位置: 移动技术网 > IT编程>网页制作>CSS > CSS Hack大全-教你如何区分出IE6-IE10、FireFox、Chrome、Opera

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

2017年12月08日  | 移动技术网IT编程  | 我要评论

江西信息网,自动排污阀,le pre lenotre

现在的浏览器ie6-ie10、firefox、chrome、opera、safari。。。数量众多,可谓百家争鸣,对用户来说有了很多的可选择型,不过这可就苦了web前端开发人员了。
今天把一些常用的css hack整理了一下,包括常用的ie hack以及火狐、chrome、opera浏览器的hack,并把这些css hack综合的一起,写了一个小的浏览器测试器。如图所示:

下面就来看一下代码吧:

html部分:

复制代码 代码如下:

<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部分的代码吧,布局的就不贴了:

复制代码 代码如下:

.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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网