例如,如果我有以下的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