假设我们有:
.first-class {
background: purple;
font-weight: bold;
color: white;
}
.first-class > .second-class {
/* code goes here */
}在.二等中,是否可以只从一等属性(例如背景)继承一个属性,而将其他属性保留为默认值?
发布于 2013-07-25 05:45:37
不是的。你得重新设置它们。.first-class是.second-class的父级,将继承它的继承。
以下是重置前演示您的场景的工作实例。
现在当你
在重置之前和之后查找以下代码。
重置前:
HTML:
<div class="first-class">
<div class="second-class">abcd</div>
</div>CSS:
.first-class {
background: purple;
font-weight: bold;
color: white;
}
.first-class > .second-class {
/* code goes here */
}重置后:
HTML:
<div class="first-class">
<div class="second-class">abcd</div>
</div>CSS:
.first-class {
background: purple;
font-weight: bold;
color: white;
}
.first-class > .second-class {
background: inherit;
font-weight:normal;
color:black;
}https://stackoverflow.com/questions/17849920
复制相似问题