I'm looking for a solid, cross-browser way of finding the following calculated dimensions from Javascript:
- content rectangle: innermost content area
- client rectangle: content area + padding
- complete rectangle: content + padding + border + margin
It doesn't have to be exactly that grouping, I'm just looking for enough info to completely decompose any box into content->padding->border->margin segments.
(I probably won't have to care about scroll bars, but if they have a well-defined behaviour as well, I wouldn't mind knowing that)
I want to be able to get these as pixel values, regardless of how they were styled from CSS. So even in the case of e.g. margin-left: auto
or width: 50%
, I want to be able to extract the computed results in pixels.
No jQuery solutions please, I'm looking for vanilla Javascript + DOM answers.