- Source:
Methods
(static) addRule(selector, style, styleElementopt) → {Number}
Create and add a style rule.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
selector |
String | a CSS selector (e.g. |
|
style |
CSSStyleDeclaration | String | style declaration (e.g. |
|
styleElement |
HTMLStyleElement |
<optional> |
an optional style element to add the rule to; by default, rules are added to a common custom style element |
- Source:
Returns:
the index of the rule within the style element rules list
- Type
- Number
(static) addValue(value, operand) → {String}
Perform an add operation on a CSS value with unit, preserving the unit.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | the CSS value (e.g. |
operand |
Number | String | the number to add |
- Source:
Returns:
- Type
- String
(static) createStyleElement() → {HTMLStyleElement}
Create an empty style element and add it to document head.
- Source:
Returns:
- Type
- HTMLStyleElement
(static) delRule(selector, styleElementopt)
Delete a style rule that matches a given selector.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
selector |
String | a CSS selector (e.g. |
|
styleElement |
HTMLStyleElement |
<optional> |
an optional style element to restrict the search to |
- Source:
(static) divValue(value, operand) → {String}
Perform a divide operation on a CSS value with unit, preserving the unit.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | the CSS value (e.g. |
operand |
Number | String | the number to divide by |
- Source:
Returns:
- Type
- String
(static) em2px(em, elemopt) → {Number}
Convert em units to pixel units.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
em |
Number | ||
elem |
jQuery |
<optional> |
optional HTML element; document's body is used by default |
- Source:
Returns:
- Type
- Number
(static) findRules(selectorRe) → {Array.<Object>}
Find all style rules that match a selector regular expression.
Parameters:
| Name | Type | Description |
|---|---|---|
selectorRe |
String | RegExp |
- Source:
Returns:
a list of objects with selector and declaration
- Type
- Array.<Object>
(static) getStyleLinkElement(filename) → (nullable) {HTMLLinkElement}
Return the link element from the DOM corresponding to a given CSS file.
Parameters:
| Name | Type | Description |
|---|---|---|
filename |
String |
- Source:
Returns:
- Type
- HTMLLinkElement
(static) mulValue(value, operand) → {String}
Perform a multiply operation on a CSS value with unit, preserving the unit.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | the CSS value (e.g. |
operand |
Number | String | the number to multiply by |
- Source:
Returns:
- Type
- String
(static) px2em(px, elemopt) → {Number}
Convert pixel units to em units.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
px |
Number | ||
elem |
jQuery |
<optional> |
optional HTML element; document's body is used by default |
- Source:
Returns:
- Type
- Number
(static) subValue(value, operand) → {String}
Perform a subtract operation on a CSS value with unit, preserving the unit.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | the CSS value (e.g. |
operand |
Number | String | the number to subtract |
- Source:
Returns:
- Type
- String
(static) unscalePx(px) → {Number}
Convert a length from visual pixels to CSS pixels.
Pointer event coordinates and getBoundingClientRect() values (so also jQuery's offset() and position()) are
visual pixels -- they include the scaling factor applied to the body. CSS lengths, em units, offsetWidth and
jQuery's width() are CSS pixels. Mixing the two is only safe when the scaling factor is 1.
Parameters:
| Name | Type | Description |
|---|---|---|
px |
Number |
- Source:
Returns:
- Type
- Number