중요도: 5
What’s the difference between getComputedStyle(elem).width
and elem.clientWidth
?
Give at least 3 differences. The more the better.
해답
Differences:
clientWidth
is numeric, while getComputedStyle(elem).width
returns a string with px
at the end.getComputedStyle
may return non-numeric width like "auto"
for an inline element.clientWidth
is the inner content area of the element plus paddings, while CSS width (with standard box-sizing
) is the inner content area without paddings.clientWidth
property is always the same: scrollbar size is substracted if reserved.