JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 337436
  • Score
    100M100P100Q202576F
  • License MIT

fast dom CSS styling

Package Exports

  • dom-css

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dom-css) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dom-css

stable

Small module for fast and reliable DOM styling.

  • detects prefixes as necessary, cached for performance
  • converts numbers to px strings for common properties
  • normalizes for camel and dash case
var css = require('dom-css')

//set a style
css(element, 'position', 'absolute')

//will be set as "WebkitFontSmoothing" on Chrome
css(element, 'font-smoothing', 'none')

//set multiple styles
css(element, {
    //can be camel or dash case
    'background-color': 'blue',

    //some properties use 'px' by default
    left: 25, 
    top: 0,
    position: 'absolute'
})

See the special cases for a list of px-suffixed properties (same list is used in GreenSock API).

Usage

NPM

css(element, property, value)

Styles an element with the css property (dash or camel case) and a given value. value is a string, or a number to be suffixed with 'px' (special cases, see below).

css(element, styles)

A shorthand for setting multiple styles, where styles is an object containing property:value pairs.

special cases

The following properties are suffixed with 'px' when their value is specified as a number.

top, right, bottom, left, 
width, height, fontSize, 
paddingLeft, paddingRight, 
paddingTop, paddingBottom, 
marginLeft, marginRight, 
marginTop, marginBottom, 
padding, margin, perspective

License

MIT, see LICENSE.md for details.