>  Q&A  >  본문

原生JS设置CSS3样式时,怎么添加兼容性前缀(-webkit-)

正常设置css3样式是这样的
obj.style.WebkitTransition = "all 1s linear";
解析出来的是
<div id="obj" style="transition: all 1s linear;"></div>
我想知道怎么加上-webkit-前缀。如下面
<div id="obj" style="-webkit-transition: all 1s linear;"></div>

大家讲道理大家讲道理2869일 전959

모든 응답(2)나는 대답할 것이다

  • 代言

    代言2016-11-12 13:48:55

    那个,如果你的元素没有内联样式的话,你可以直接obj.style.cssText="-webkit-transition: all 1s linear;...;"试试看

    회신하다
    0
  • 代言

    代言2016-11-12 13:48:48

    你有用webpack、gulp、grunt这些工具么- -或者有编辑器吧,弄个Autoprefixer就行了- -手写很麻烦。。而且可维护性不好,以后突然其中一个前缀不需要了,你又要手动去改

    회신하다
    0
  • 취소회신하다