https://github.com/jonkemp/css-property
CSS property constructor
https://github.com/jonkemp/css-property
inline-css
Last synced: about 1 month ago
JSON representation
CSS property constructor
- Host: GitHub
- URL: https://github.com/jonkemp/css-property
- Owner: jonkemp
- License: mit
- Created: 2015-01-20T13:36:43.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-10-08T22:27:45.000Z (over 5 years ago)
- Last Synced: 2025-02-08T20:32:18.021Z (about 1 year ago)
- Topics: inline-css
- Language: JavaScript
- Size: 145 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# css-property [](https://travis-ci.org/jonkemp/css-property) [](https://coveralls.io/github/jonkemp/css-property?branch=master)
[](https://nodei.co/npm/css-property/)
> CSS property constructor
## Install
Install with [npm](https://npmjs.org/package/css-property)
```
npm install --save css-property
```
## Usage v2
```js
var selector = require('style-selector'),
property = require('css-property'),
bodySelector = selector('body'),
prop = property('font-family', 'Arial', bodySelector);
console.log(prop.prop); // font-family
console.log(prop.value); // Arial
console.log(prop.selector.text); // body
console.log(prop.toString()); // font-family: Arial;
```
## Usage v1
```js
var Selector = require('style-selector'),
Property = require('css-property'),
bodySelector = new Selector('body'),
prop = new Property('font-family', 'Arial', bodySelector);
console.log(prop.prop); // font-family
console.log(prop.value); // Arial
console.log(prop.selector.text); // body
console.log(prop.toString()); // font-family: Arial;
```
## v2 API
### property(prop, value, selector)
#### prop
Type: `String`
Default: `none`
Property
#### value
Type: `String`
Default: `none`
Value
#### selector
Type: `Object`
Default: `none`
Selector the property originates from.
### property.compare(property)
Compares with another Property based on Selector#specificity.
#### property
Type: `Object`
Default: `none`
Property to compare.
#### property.toString()
Returns CSS property.
## v1 API
### Property(prop, value, selector)
#### prop
Type: `String`
Default: `none`
Property
#### value
Type: `String`
Default: `none`
Value
#### selector
Type: `Object`
Default: `none`
Selector the property originates from.
### Property.prototype.compare(property)
Compares with another Property based on Selector#specificity.
#### property
Type: `Object`
Default: `none`
Property to compare.
#### Property.prototype.toString()
Returns CSS property.
## Credit
The code for this module was originally taken from the [Juice](https://github.com/Automattic/juice) library.
## License
MIT