taoliujun / blog

https://taoliujun.github.io/blog/
https://taoliujun.github.io/blog/
0 stars 0 forks source link

Web API - CSS Properties and Values #67

Open taoliujun opened 7 months ago

taoliujun commented 7 months ago

CSS Properties and Values

MDN: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Properties_and_Values_API

CSS Properties and Values用于为CSS扩展属性,

CSS variables有类似点,但后者只是一个变量,没有CSS属性之特性:比如继承特性。

接口

CSSPropertyRule

属性和值的定义描述。

syntax选项标识了值的预期语法,如<color>

方法

registerProperty

创建自定义css属性。

示例

示例:https://taoliujun.github.io/example/web-api/CSS_Properties_and_Values_API/index.html

  1. 两个Div使用了一样的样式,但registerProperty注册了非继承的属性,所以.parent1 .item1并未继承.parent1中设置的属性值,而使用了默认值。

image