Native JS css property acquisition element

JS get the stylesheet elements:

var style = null;
    if (window.getComputedStyle) {     //判断浏览器类型
        style = window.getComputedStyle(box, null);    // 非IE
    } else {
        style = box.currentStyle;  // IE
    };

All styles style attributes are
for example:
element width: style.width,
element height: style.height

Guess you like

Origin blog.csdn.net/qq_36427929/article/details/77920818