Skip to content
Toke Voltelen edited this page Dec 3, 2016 · 4 revisions

size([elm])

Finds the size of a HTML Element or the window.

Parameters

  • elm (HTMLElement) - [default=viewport] The HTML element (or window) to find the size of
  • returns (SizeData) - Object describing the various sizes of an element

SizeData

  • width (Number) - The total width of the element (with border etc.)
  • height (Number) - The total height of the element (with border etc.)
  • innerWidth (Number) - The width of the elements view area (without border etc.)
  • innerHeight (Number) - The height of the elements view area (without border etc.)
  • contentWidth (Number) - The width of content of the element
  • contentHeight (Number) - The height of content of the element

Usage

import size from 'vanillajs-browser-helpers/size';

// The viewport size
size();
// or
size(viewport);

// The window size
size(window);

// A HTML element size
size(element);
Clone this wiki locally