Giter Club home page Giter Club logo

style.js's Introduction

style.js

Light-Weight Javascript Style Wrapper

Installation

Using Bower:

bower install style.js

Or grab the source (minified).

Usage

Basic usage is as follows:

// Read a style
style(myHTMLElement)('font-size');

// Write a style
style(myHTMLElement)('font-size', '12px');

// Can write without pixel units
style(myHTMLElement)('font-size', 14);

// Can read without units too (returns a number)
style(myHTMLElement).unitless('font-size');
style(myHTMLElement).u('font-size'); // alias

// The Style function is also alised to S
S(myHTMLElement)('font-size', '2em');

// To remove a property, call with undefined
S(myHTMLElement)('font-size', undefined);

// Or with a CSS function
S(myHTMLElement)('transform', ['translate', '50%', '50%']);

Note that, the wrapper function will cache the computed styles. It will remove the cache when something is written. Do not set styles from elsewhere or else the cache will become invalid!

Contributing

We'll check out your contribution if you:

  • Provide a comprehensive suite of tests for your fork.
  • Have a clear and documented rationale for your changes.
  • Package these up in a pull request.

We'll do our best to help you out with any contribution issues you may have.

License

MIT. See LICENSE.txt in this directory.

style.js's People

Contributors

mjc-gh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nomnomcameron

style.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.