1. getComputedStyle(属性多)
获取当前元素所有最终使用的CSS属性值,返回一个只读的对象
style (属性少)可写
var dom = document.getElementById(‘btn‘)var a = window.getComputedStyle(dom,null)var b = dom.styleconsole.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(‘属性名‘)
两种方式的不同在于有时值一样,属性名是不一样的
CSS属性
原文地址:https://www.cnblogs.com/xiaobai1/p/8732941.html