From 9f4ae674a3f256e637b6539363f76a323e96f20c Mon Sep 17 00:00:00 2001 From: Mars Yao Date: Tue, 16 Mar 2021 01:40:33 +0800 Subject: Add and translate pages about @property. (#171) * 'add_@property_contents' --- files/zh-cn/web/css/@property/inherits/index.html | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 files/zh-cn/web/css/@property/inherits/index.html (limited to 'files/zh-cn/web/css/@property/inherits/index.html') diff --git a/files/zh-cn/web/css/@property/inherits/index.html b/files/zh-cn/web/css/@property/inherits/index.html new file mode 100644 index 0000000000..c2421f9535 --- /dev/null +++ b/files/zh-cn/web/css/@property/inherits/index.html @@ -0,0 +1,100 @@ +--- +title: '继承性' +slug: Web/CSS/@property/inherits +tags: + - CSS + - Reference + - Web + - Property + - Houdini +--- +
{{CSSRef}}{{SeeCompatTable}}
+ +

inherits CSS 描述符在使用{{cssxref("@property")}} {{cssxref("at-rule")}}时是必需的,它控制由 @property声明注册的自定义属性默认情况下是否会被继承。

+ +

Syntax(类型描述符)

+ +
@property --property-name {
+  syntax: '<color>';
+  inherits: false;
+  initial-value: #c0ffee;
+}
+
+@property --property-name {
+  syntax: '<color>';
+  inherits: true;
+  initial-value: #c0ffee;
+}
+
+ +

取值

+ +
+
true
+
属性默认继承
+
false
+
属性默认不继承
+
+ +

规范定义

+ +

{{cssinfo}}

+ +

标准语法

+ +
{{csssyntax}}
+ +

实例

+ +

--my-color {{cssxref('--*', '自定义属性')}}添加颜色值类型检测、设置默认值并且设置属性值不允许被继承。

+ +

使用 CSS {{cssxref('@property')}} @规则:

+ +
@property --my-color {
+  syntax: '<color>';
+  inherits: false;
+  initial-value: #c0ffee;
+}
+
+ +

使用 JavaScript中的 {{domxref('CSS.registerProperty')}}函数:

+ +
window.CSS.registerProperty({
+  name: '--my-color',
+  syntax: '<color>',
+  inherits: false,
+  initialValue: '#c0ffee',
+});
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态提议
{{SpecName('CSS Properties and Values API', '#inherits-descriptor', 'inherits')}}{{Spec2('CSS Properties and Values API')}}初始定义.
+ +

浏览器兼容性

+ + + +

{{Compat("css.at-rules.property.inherits")}}

+ +

另见

+ + \ No newline at end of file -- cgit v1.2.3-54-g00ecf