例如,如果我有以下的HTML:是否可以引用另一个CSS规则?
<div class="someDiv"></div>
这个CSS:
.opacity {
filter:alpha(opacity=60);
-moz-opacity:0.6;
-khtml-opacity: 0.6;
opacity: 0.6;
}
.radius {
border-top-left-radius: 15px;
border-top-right-radius: 5px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
}
.someDiv {
background: #000; height: 50px; width: 200px;
/*** How can I reference the opacity and radius classes here
so this div has those generic rules applied to it as well ***/
}
怎么样的脚本语言,你有使用常写在脚本的顶部通用功能和每次需要使用该功能时,只需调用该函数,而不是每次重复所有代码。
多个类是没可能来更改HTML? – BoltClock 2010-10-30 19:55:35
您可以在'.radius'中添加逗号分隔的类列表,如'.radius,.another,.element {/ * css * /}'。这将为您节省额外的代码,但可能会降低可读性。 – Lekensteyn 2010-10-30 19:56:38
[CSS类是否可以继承一个或多个其他类?](https://stackoverflow.com/questions/1065435/can-a-css-class-inherit-one-or-more-other-classes) – 2017-09-21 21:46:14