例如,如果我具有以下HTML:
<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 ***/
}
就像在脚本语言中一样,您具有通常在脚本顶部编写的通用函数,并且每次需要使用该函数时,只需调用该函数即可,而不必每次都重复所有代码。
.radius
,例如.radius, .another, .element{/* css*/}
。这将为您节省额外的代码,但可能使其可读性降低。