相关疑难解决方法(0)

是否可以在另一个中引用一个CSS规则?

例如,如果我有以下HTML:

<div class="someDiv"></div>
Run Code Online (Sandbox Code Playgroud)

这个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 ***/

}
Run Code Online (Sandbox Code Playgroud)

就像在脚本语言中一样,你拥有通常在脚本顶部编写的泛型函数,每次你需要使用该函数时,你只需调用函数而不是每次都重复所有代码.

css

95
推荐指数
4
解决办法
13万
查看次数

标签 统计

css ×1