domcss.js

0.1.2 • Public • Published

domcss.js NPM

Compute CSS properties and position of DOM elements.

Developed by Florian Eckerstorfer (@Florian_) in Vienna, Europe.

Installation

You can install domcss.js from NPM:

$ npm install domcss.js

Usage

If you are interesting in (nearly) every CSS property property:

var domCSS = new DomCSS();

However, you can also define the properties that domcss.js should compute:

var domCSS = new DomCSS(['font-family', 'font-size', 'color']);

attachToDOM()

Compute CSS and position for all elements in <body> and attach to DOM:

domCSS.attachToDOM(document.body);
// document.body.children[0].computedPosition -> {"x1": 8, "x2": 138.671875, "y1": 0, "y2": 32}
// document.body.children[0].computedCSSProperties -> {"color": "rgb(0, 0, 238)", ...}

computeStyles()

Compute CSS properties for a specific element:

domCSS.computeStyles(document.querySelector('#main'));
// -> {"color": "rgb(0, 0, 238)", "font-family": "Times", "font-size": "32px", ...}

computeStyle()

Compute specific CSS property

domCSS.computeStyle(document.querySelector('#main'), 'font-size');
// -> "32px"

computePosition()

Compute position for a specific element:

domCSS.computePosition(document.querySelector('#main'));
// -> {"x1": 8, "x2": 138.671875, "y1": 0, "y2": 32}

Readme

Keywords

Package Sidebar

Install

npm i domcss.js

Weekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • florianeckerstorfer