css-styler

1.0.0 • Public • Published

CSS Styler

A fast and lightweight cross-browser function for setting and getting DOM styles. 6x faster than using jQuery.css().

Install

NPM + Browserify (recommended)

First install CSS Styler in your project root.

$ npm install css-styler

Then include in your module using require().

var css = require('css-styler');

File include

Download the latest css.global.min.js from http://github.com/InventingWithMonster/css-styler and include it in your HTML document with a script tag, ie:

<script src="/path/to/css.global.min.js"></script>

This will load CSS Styler to the global scope as window.css, accessible in any script executed subsequently.

Use

CSS Styler takes two arguments: Your DOM element, and either an object of CSS properties (to set), or the name of a CSS property (to get). It will automatically find any prefixed versions of your property and set those instead.

Set

css(domElement, {
    transform: 'translate3d(10px, 0, 0)', // In a -webkit- prefixed browser, would set WebkitTransform instead
    backgroundColor: '#F00'
});

Get

css(domElement, 'backgroundColor'); // Returns '#F00'

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i css-styler

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • inventingwithmonster