🔸.boundingBox
browser ⟩ DOM ⟩ type ⟩ Element ⟩ boxes ⟩ Element+boxes ⟩ .boundingBox
size: (may be fractional)
almost the same as .borderBox size (integer-valued).
"box-sizing: border-box" size = (width, height) -> padding/border included.
👉 compare: .borderBox (a Rect relative to .offsetParent)
💾 Element+boxes, 👉 coordinates
the elements must be in the document to read offsetHeight and other properties, a hidden (display:none) or out of the document element has no size.
inline elements (such as <span>, <code>, <b>)
may span multiple lines and consist of multiple rectangles.
the bounding rect returned by .getBoundingClientRect() will include the entire width/height of these lines.
call .getClientRects() to get individual rectangles of inline elements.
coordinates of document / viewport / container
elem.position() - document coordinates of Element
will change while window scrolling
elem.position() - document coordinates of Element.
💾 replit: elem.getBoundingClientRect()
Element ⟩
.getClientRects() - individual rectangles of inline elements.
Last updated
Was this helpful?