The first case is that the width and height are written in the style sheet, like #div1{width:120px;}. In this case,
Over #div1. Style.width can not reach the width, but through the #div1.offsetwidth to get to the width.
The second case is that the width and height are written in the line, for example, the case
All of the above 2 methods can be used to get the width.
Summary, because Id.offsetwidth and id.offsetheight ignore styles written in style sheets or inline, so
It's best to use these 2 attributes when we get the element width and height . Note If you are not writing in the style in the row
Properties are not available through ID.STYLE.ATRR.
Today's front-end Productions seldom write styles directly in style, they are written in the style table. If you want to get
Style does not correspond (just like #div1.style.width corresponds to #div1.offsetwidth), it is only
Can be used to get the properties of the style sheet without a browser, you can try to search "JS get style genus
Sex "or something like that.
var o = document.getElementById ("view"); var h = o.offsetheight; Height var w = o.offsetwidth; Width