zoukankan      html  css  js  c++  java
  • 浏览器前缀

    记录一下。

    CSS:-moz- -o- -ms- -webkit-

    JS:Moz O ms Webkit

    e.g. 

    MozAnimationName -moz-animation-name
    OAnimationName -o-animation-name
    msAnimationName -ms-animation-name
    WebkitAnimationName -webkit-animation-name

    Modernizr这个库的源码中看到他检查浏览器的前缀就是这么用的。

    /**
     * 检查是否支持CSS3动画
     */
    prototype.isSupportAnimation = function () {
        if (this._isSupportAnimation != null) {
            return this._isSupportAnimation;
        }
        var fn = function () {
            // 检查是否支持CSS3动画
            var cssProps = 'animation-name -webkit-animation-name -moz-animation-name -ms-animation-name -o-animation-name'.split(' '),
                jsProps = 'animationName WebkitAnimationName MozAnimationName msAnimationName OAnimationName'.split(' '),
                style = doc.createElement('div').style,
                i;
            // 1.先用原生的方法检查是否支持
            if ('CSS' in win && 'supports' in win.CSS) {
                for (i = 0; i < cssProps.length; i++) {
                    if (win.CSS.supports(cssProps[i], 'a')) {
                        return true;
                    }
                }
            }
            // 2.再手动检测
            for (i = 0; i < jsProps.length; i++) {
                if (style[jsProps[i]] !== undefined) {
                    return true;
                }
            }
            return false;
        };
        return this._isSupportAnimation = fn();
    };
    

     浏览器前缀检测css-vendor

  • 相关阅读:
    win中使用curl上传文件报错
    S2-052
    S2-048
    S2-045、S2-046
    S2-033、S2-037
    S2-032
    S2-029
    day12-python之深灰魔法
    day10-11-python基础之字符串
    day09-python基础
  • 原文地址:https://www.cnblogs.com/ystrdy/p/8267682.html
Copyright © 2011-2022 走看看