<div id="box" class="box">
sss
</div>
Use external style file 1.css:
*{
margin: 0;
padding: 0;
}
.box{
width: 320px;
background: #f00;
transform:translateX(30px);
}
JS get the current style method:
let getStyle = function(tag,prop){
return tag.currentStyle? tag.currentStyle[prop] : getComputedStyle(tag)[prop] ;
};
let box = document.getElementById("box");
console.info( getStyle(box,"width")); // 320px