Creates a CSS stylesheet from an JSON representation of a stylesheet.

This function is valid in v2.1.0 to v2.12.0. This function has been downloaded 9 times.


{Object} objStyles
An object representing the CSS rules to be inserted into the document. Property names will be used as media queries if they start with "@media ". Property names will be used as rule selectors if the value is an object. If a property name is to be used as a selector, if any selectors don't contain &, "& " will be prepended to it. For all selectors, & will be replaced recursively with the selectors found in the parent. CSS property names will be uncamelcased by inserting dashes before each uppercased character and lower casing all characters. If a value is null or undefined, it will be turned into "none". If a value is a number other than 0, "px" will be appended to it. If a value is an array all of the items will be concatenated together, using "," to delimit the values. If a value ends with ! it will be replaced with "!important".
{HTMLElement|Array.|string} opt_ancestors
This can be an element or an array of elements which will get another class added to target all rules to it and its children. This can alternatively be a CSS path (selector) specifying the root on which all CSS rules created should be based.


The stylesheet that is created and appended to the document is returned.

Required Functions

This function requires the following functions which are included automatically:

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.