zoukankan      html  css  js  c++  java
  • css区分ie8/ie9/ie10/ie11 chrome firefox的代码

    以下是几个主要浏览器的css  hack汇总:

    现有css样式为:

    .class{
       color:red;
    }

    判断IE8以上的浏览器才执行的代码
    /*
    IE8+ */ .class{ color:red0; } 
    /* IE8、9 */
    .class{
        color:red890;
    }
    /* IE9 */
    .class{
        color:red90;
    }

    注意,8的写法是错误的,不能试图这样hack IE8。上述代码没有对IE10和IE11分别hack(好像没有对这两个浏览器单独hack的写法),那么IE10和IE11使用的就是IE8+那个样式

    /* Chrome */
    @media screen and (-webkit-min-device-pixel-ratio:0) {
        .class{
           color:red;
        }
    }
    /* Firefox */
    @-moz-document url-prefix() {
        .class{
            color:red;
        }
    }

    另外,还可以这样hack其他浏览器

    /* Chrome 和 opera */
    @media all and (min-0){
        .class{
            color:red;
        }
    }
    /* IE9+ */
    @media all and (min-0) {
        .class{
            color:red;
        }
    }
    /* IE10+ */
    @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)  {
        .class{
            color:red;
        }
    }
  • 相关阅读:
    定位 -CLGeocoder
    定位
    定位
    定位- 汽车导航
    定位
    SVN
    githubRepository -- 使用
    git 常用指令
    ipad ------ 与iPhone的差别
    总结
  • 原文地址:https://www.cnblogs.com/xmxxn/p/8057948.html
Copyright © 2011-2022 走看看