CSS🧪
该域公开了CSS的读写操作。所有CSS对象(样式表、规则和样式)都有一个关联的id,用于后续对相关对象的操作。每种对象类型都有特定的id结构,这些结构在不同类型的对象之间不可互换。CSS对象可以通过get*ForNode()调用(接受DOM节点id)加载。客户端还可以通过styleSheetAdded/styleSheetRemoved事件跟踪样式表,随后使用getStyleSheet[Text]()方法加载所需的样式表内容。
EN
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
🔨CSS.addRule
在指定的 styleSheetId 样式表中,根据 location 指定的位置,插入一条包含给定 ruleText 的新规则。
EN
Inserts a new rule with the given
ruleText in a stylesheet with given styleSheetId, at the position specified by location.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| styleSheetId | ✔️ | DOM.StyleSheetId | css样式表标识符,用于指定新规则应插入的位置。 | ENThe css style sheet identifier where a new rule should be inserted. | |
| ruleText | ✔️ | string | 新规则的文本。 | ENThe text of a new rule. | |
| location | ✔️ | SourceRange | 目标样式表中新规则的文本位置。 | ENText position of a new rule in the target style sheet. | |
| nodeForPropertySyntaxValidation | 🧪 | DOM.NodeId | 注册属性自定义属性声明的验证应在哪个DOM节点的上下文中进行,其NodeId。如果省略,新规则文本中的声明只能进行静态验证,例如,如果声明包含var(),则可能产生不正确的结果。 | ENNodeId 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. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| rule | CSSRule | 新创建的规则。 | ENThe newly created rule. |
🔨CSS.collectClassNames
从指定样式表中返回所有类名。
EN
Returns all class names from specified stylesheet.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| styleSheetId | ✔️ | DOM.StyleSheetId |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| classNames | array[string] | 类名列表。 | ENClass name list. |
🔨CSS.createStyleSheet
在给定的 frameId 框架中创建一个新的特殊 "via-inspector" 样式表。
EN
Creates a new special "via-inspector" stylesheet in the frame with given
frameId.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| frameId | ✔️ | Page.FrameId | 应在其中创建“via-inspector”样式表的框架标识符。 | ENIdentifier of the frame where "via-inspector" stylesheet should be created. | |
| force | boolean | 如果为真,每次调用都会创建一个新的样式表。如果为假,则返回先前通过调用(force=false)为该框架文档创建的样式表(如果存在),否则创建一个新的样式表(默认值:false)。 | ENIf 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). |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| styleSheetId | DOM.StyleSheetId | 创建的“via-inspector”样式表的标识符。 | ENIdentifier of the created "via-inspector" stylesheet. |
🔨CSS.disable
禁用给定页面的CSS代理。
EN
Disables the CSS agent for the given page.