继承css属性
我对css只有基本的了解,有没有可能从一种样式继承属性到另一种样式.例如,我可以将默认段落标记设置中指定的字体大小继承到超链接标记中.
I have only a basic knowledge of css, is it possible to inherit a property from one style into another style. So for instance I could inherit the font size specified in my default paragrah tag settings into my hyperlink tags.
我想这样做的原因是为了更容易维护多种样式.
The reason I want to do this is to make it easier to maintain multiple styles.
您可以像这样同时为两个元素定义通用样式:
You can define common styles for two elements at once like so:
p, a {
font-size: 1em;
}
然后根据需要扩展每个属性:
And then extend each one with their individual properties as you want:
p {
color: red;
}
a {
font-weight: bold;
}
请记住:在样式表中稍后定义的样式通常会覆盖之前定义的属性.
Keep in mind: Styles defined later in a style sheet generally override properties defined earlier.
额外:如果您还没有,我建议您获取 FirebugFirefox 扩展,以便您可以查看页面上的元素接收的样式以及它们从何处继承.
Extra: If you haven't already, I recommend getting the Firebug Firefox extension so you can see what styles the elements on your page are receiving and where they are inherited from.