Print Friendly

# Class Ext.util.CSS

Package: | Ext.util
Class: | CSS
Extends: | Object
Defined In: | CSS.js

Utility class for manipulating CSS rules
This class is a singleton and cannot be created directly.
Properties - Methods - Events

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| createStyleSheet(`String cssText`) : StyleSheet | CSS
Very simple dynamic creation of stylesheets from a text blob of rules. The text will wrapped in a style tag and appe...
| getRule(`String/Array selector`, `Boolean refreshCache`) : CSSRule | CSS
Gets an an individual CSS rule by selector(s)
| getRules(`Boolean refreshCache`) : Object | CSS
Gets all css rules for the document
| refreshCache() : Object | CSS
Refresh the rule cache if you have dynamically added stylesheets
| removeStyleSheet(`String id`) : void | CSS
Removes a style or link tag by id
| swapStyleSheet(`String id`, `String url`) : void | CSS
Dynamically swaps an existing stylesheet reference for a new one
| updateRule(`String/Array selector`, `String property`, `String value`) : Boolean | CSS
Updates a rule property

## Public Events

This class has no public events.

## Method Details

### createStyleSheet

`public function createStyleSheet(`String cssText`)`
Very simple dynamic creation of stylesheets from a text blob of rules. The text will wrapped in a style tag and appended to the HEAD of the document.
Parameters:

- `cssText` : String
  The text containing the css rules

Returns:

- `StyleSheet`

This method is defined by CSS.

### getRule

`public function getRule(`String/Array selector`, `Boolean refreshCache`)`
Gets an an individual CSS rule by selector(s)
Parameters:

- `selector` : String/Array
  The CSS selector or an array of selectors to try. The first selector that is found is returned.
- `refreshCache` : Boolean
  true to refresh the internal cache if you have recently updated any rules or added styles dynamically

Returns:

- `CSSRule`
  The CSS rule or null if one is not found

This method is defined by CSS.

### getRules

`public function getRules(`Boolean refreshCache`)`
Gets all css rules for the document
Parameters:

- `refreshCache` : Boolean
  true to refresh the internal cache

Returns:

- `Object`
  An object (hash) of rules indexed by selector

This method is defined by CSS.

### refreshCache

`public function refreshCache()`
Refresh the rule cache if you have dynamically added stylesheets
Parameters:

- None.

Returns:

- `Object`
  An object (hash) of rules indexed by selector

This method is defined by CSS.

### removeStyleSheet

`public function removeStyleSheet(`String id`)`
Removes a style or link tag by id
Parameters:

- `id` : String
  The id of the tag

Returns:

- `void`

This method is defined by CSS.

### swapStyleSheet

`public function swapStyleSheet(`String id`, `String url`)`
Dynamically swaps an existing stylesheet reference for a new one
Parameters:

- `id` : String
  The id of an existing link tag to remove
- `url` : String
  The href of the new stylesheet to include

Returns:

- `void`

This method is defined by CSS.

### updateRule

`public function updateRule(`String/Array selector`, `String property`, `String value`)`
Updates a rule property
Parameters:

- `selector` : String/Array
  If it's an array it tries each selector until it finds one. Stops immediately once one is found.
- `property` : String
  The css property
- `value` : String
  The new value for the property

Returns:

- `Boolean`
  true If a rule was found and updated

This method is defined by CSS.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.