我有几个css类,我想在一个元素上指定.但我不想每次都重复上3次,4次或更多次课程.
我想去
<span class ="class1 backgroundclass borderclass iconclass">Link</span>
Run Code Online (Sandbox Code Playgroud)
至
<span class="linkClass">Link</span>
Run Code Online (Sandbox Code Playgroud)
可以这样做吗?如果是这样,怎么样?
In normal CSS, you would have to include .linkClass into every class definition like this:
.class1, .linkClass { ...... }
.backgroundclass, .linkClass { ...... }
.borderclass, .linkClass { ...... }
Run Code Online (Sandbox Code Playgroud)
Not very good for readability.
You could look into CSS pre-processors like LessCSS that make this easier. With LessCSS, it seems to be possible to do the following:
.linkClass {
.class1;
.backgroundclass;
.borderclass;
}
Run Code Online (Sandbox Code Playgroud)
然后LessCSS将编译最终的样式表.