CSS继承关键字示例 [英] Example of css inherit keyword
本文介绍了CSS继承关键字示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要在CSS中使用继承关键字的示例是什么?
What is an example of needing to use the inherit keyword in css?
推荐答案
假设我们需要所有锚点文字为橙色:
Let's say we want all of our anchor text to be orange:
a { color: orange }
我们希望所有div文本均为绿色:
And we want all of our div text to be green:
div { color: green }
如果我们希望div中的锚点也变为绿色怎么办?在这里,我们可以使用继承:
What if we want anchors within divs to also be green? Here, we can use inherit:
div > a { color: inherit }
以下HTML代码段可能会更清楚:
The following HTML snippet might make this clearer:
<a href="#">I'm orange</a>
<div>I'm green!</div>
<div>I'm green and <a href="#">green</a>!</div>
这篇关于CSS继承关键字示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文