CSS样式继承 [英] CSS Style Inheritance
本文介绍了CSS样式继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我想定义2个样式。
Lets say I want to define 2 styles.
.color_red { color: Red; }
.banner { display: block; width: 100%; }
有没有办法让h1风格继承color_red风格?我不想这样做
Is there a way that I can have the h1 style inherit the color_red style? I don't want to have to do
<div class="banner color_red">This is my banner.</div>
我喜欢这样做...
.banner { ... inherit: color_red; }
...
<div class="banner">This is my banner.</div>
横幅有红色文字。
推荐答案
您必须写:
.color_red, .banner { color: Red; }
.banner { display: block; width: 100%; }
这篇关于CSS样式继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文