当前位置: 移动技术网 > IT编程>网页制作>CSS > CSS属性

CSS属性

2018年04月10日  | 移动技术网IT编程  | 我要评论

一人一本t3,电脑算命婚姻,思兔阅读

1.  getComputedStyle(属性多)
获取当前元素所有最终使用的CSS属性值,返回一个只读的对象

     style (属性少)可写

 

var dom = document.getElementById('btn')
var a = window.getComputedStyle(dom,null)
var b = dom.style
console.log(a);
console.log(b);

  


2.currentStyle 与getComputedStyle 作用一样,只不过浏览器适用不一样

function css(元素, 属性){
    if(obj.currentStyle){ //ie使用
    return obj.currentStyle[属性];
    } else { //火狐与chrome
    return getComputedStyle(元素, 伪类,没有为null)[属性];
    }
}

  


获取css属性值 :

1.键值对
2.getProperValue :window.getComputedStyle(element,伪类).getProperValue('属性名')
两种方式的不同在于有时值一样,属性名是不一样的

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

相关文章:

验证码:
移动技术网