CSS继承和Initial之间有什么区别? [英] What's the difference between CSS inherit and initial?

查看:141
本文介绍了CSS继承和Initial之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

inheritinitial在CSS方面到底有什么区别? 对我来说,他们始终如一地工作,例如:

What exactly is the difference between inherit and initial in terms of CSS? For me they always worked the same, for example:

a.no-style{color: inherit}

将与

a.no-style{color: initial}

推荐答案

每个CSS属性的定义摘要中给出的初始值对于继承和非继承属性具有不同的含义.

The initial value given in the summary of the definition of each CSS property has different meaning for inherited and non-inherited properties.

对于继承的属性,当未为元素指定任何值时,仅对根元素使用初始值.

For inherited properties, the initial value is used, for the root element only, when no value is specified for the element.

对于非继承属性,如果未为元素指定任何值,则对任何元素使用初始值.

For non-inherited properties the initial value is used, for any element, when no value is specified for the element.

CSS3中添加了一个初始关键字,以允许作者显式指定此初始值.

An initial keyword is being added in CSS3 to allow authors to explicitly specify this initial value.

Inherit关键字表示使用分配给我父母的任何值.

The inherit keyword means use whatever value is assigned to my parent.

来源: https://developer.mozilla.org/en -US/docs/Web/CSS/initial_value

这篇关于CSS继承和Initial之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆