CSS Domain
This domain exposes CSS read/write operations. All CSS objects (stylesheets, rules, and styles)
have an associated id
used in subsequent operations on the related object. Each object type has
a specific id
structure, and those are not interchangeable between objects of different kinds.
CSS objects can be loaded using the get*ForNode()
calls (which accept a DOM node id). A client
can also keep track of stylesheets via the styleSheetAdded
/styleSheetRemoved
events and
subsequently load the required stylesheet contents using the getStyleSheet[Text]()
methods.
Methods
Events
Types
Methods
CSS.addRule #
Inserts a new rule with the given ruleText
in a stylesheet with given styleSheetId
, at the
position specified by location
.
parameters
- styleSheetId
-
StyleSheetId
The css style sheet identifier where a new rule should be inserted.
- ruleText
-
string
The text of a new rule.
- location
-
SourceRange
Text position of a new rule in the target style sheet.
- nodeForPropertySyntaxValidation
-
DOM.NodeId
NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example.
Return Object
- rule
-
CSSRule
The newly created rule.
CSS.collectClassNames #
Returns all class names from specified stylesheet.
parameters
- styleSheetId
-
StyleSheetId
Return Object
- classNames
-
array[ string ]
Class name list.
CSS.createStyleSheet #
Creates a new special "via-inspector" stylesheet in the frame with given frameId
.
parameters
- frameId
-
Page.FrameId
Identifier of the frame where "via-inspector" stylesheet should be created.
- force
-
boolean
If true, creates a new stylesheet for every call. If false, returns a stylesheet previously created by a call with force=false for the frame's document if it exists or creates a new stylesheet (default: false).
Return Object
- styleSheetId
-
StyleSheetId
Identifier of the created "via-inspector" stylesheet.
CSS.disable #
Disables the CSS agent for the given page.
CSS.enable #
Enables the CSS agent for the given page. Clients should not assume that the CSS agent has been enabled until the result of this command is received.
CSS.forcePseudoState #
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
parameters
- nodeId