I have “div” element with specified width and height expressed in percents in CSS.
I would like to get by JS script its width and height expressed in pixels. It’s even possible?
I have div element with specified width and height expressed in percents in CSS.
Share
You can use
(
elis a reference to the element)Demo
Note those properties were first introduced in the MS IE DHTML object model. More recently they were standardized in CSSOM View Module, W3C Working Draft 22 February 2008.
Those properties were widely supported. However, it’s possible than an old non-MS compliant browser doesn’t support them. In those cases, you can use
getComputedStyle:Demo
Browser support of
getComputedStyleandclientHeight/clientWidthway is at least:(
<=nmeans that it’s supported at least from versionn, but I couldn’t test previous versions)