Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PixnBits/css-prefix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css-prefix

Insert a prefix into css documents.

build status

example

var fs = require('fs');
var src = fs.readFileSync(__dirname + '/beep.css', 'utf8');

var insertPrefix = require('css-prefix');
var dst = insertPrefix('RAWR-', src);
console.log(dst);

beep.css:

#beep div.boop.killer-robots {
    color: red;
}

#beep .friendly-robots {
    color: green;
}

output:

#RAWR-beep div.RAWR-boop.RAWR-killer-robots {
    color: red;
}

#RAWR-beep .RAWR-friendly-robots {
    color: green;
}

methods

var insertPrefix = require('css-prefix')

insertPrefix(opts, src)

Insert the string opts.prefix before every class and id in the css source string src, returning the transformed source.

If opts.elementClass is given, add this class to all element identifiers. This is useful so that your h1 { color: green; } declarations don't leak into the environment.

If opts.parentClass is given, add an ancestor class to every rule.

If opts.parentId is given, add an ancestor id to every rule.

If both opts.parentClass and opts.parentId are given, they will be the same ancestor (#parent-id.parent-class).

If opts is a string, treat opts as opts.prefix.

install

With npm do:

npm install css-prefix

license

MIT

About

insert a prefix into every class and identifier in a css document

Resources

Stars

Watchers

Forks

Packages

No packages published