getSize
Finds the available width and height for a specified HTMLElement, traversing it’s parents until it finds something with constrained dimensions. Falls back to the inner dimensions of the browser window if none is found.
Basic example
Section titled “Basic example”Returns [width, height] available to an element. Each dimension comes from the element itself when it has one, minus padding and borders; otherwise the search walks up to the first ancestor that does, ending at the window’s inner size. Here the inner div fills its parent’s width but has no height, so the height is borrowed from the 150px box. Charts call this to size themselves to their container.
import {getSize} from "@d3plus/dom";
getSize(document.querySelector(".target"));
Parameters
import {getSize} from "@d3plus/dom";
elemrequiredHTMLElement