computed-styles

Get the computed styles of a DOM element in a cross browser consistent manner

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
computed-styles
701.1.27 years ago7 years agoMinified + gzip package size for computed-styles in KB

Readme

computed-style
!NPM versionnpm-imagenpm-url !Build Statustravis-imagetravis-url !Downloadsdownload-badgenpm-url
Get the computed styles of a DOM element in a cross browser consistent manner

Install

npm install computed-styles

Usage

Get computed styles

import computedStyles from 'computed-styles';

computedStyles(document.querySelector('#node')) // returns computed styles as an object

Convert computed styles to inline styles

import computedStyles from 'computed-styles';

var node = document.querySelector('#node');
computedStyles(node, node.styles);

Copy computed styles to another element

import computedStyles from 'computed-styles';

var source = document.querySelector('#source');
var target = document.querySelector('#target');
computedStyles(source, target.styles);

See API

License

MIT © J. Harshbarger