CSS类可以继承一个或多个其他类吗?
对于成为一名网络程序员这么长时间并且不知道这个问题的答案,我感到很愚蠢,我真的希望这是可能的,而我只是不知道,而不是我认为的答案(这是不可能的) 。
我的问题是,是否可以创建一个CSS类(从另一个CSS类(或多个)“继承”)。
例如,假设我们有:
.something { display:inline }
.else { background:red }
我想要做的是这样的事情:
.composite
{
.something;
.else
}
“.composite”类将以内联方式显示并具有红色背景
有像LESS这样的工具,它允许您在更高级别的抽象层次上撰写CSS,与您所描述的类似。
少调用这些“Mixins”
代替
/* CSS */
#header {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
#footer {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
你可以说
/* LESS */
.rounded_corners {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
#header {
.rounded_corners;
}
#footer {
.rounded_corners;
}
您可以将多个类添加到单个DOM元素,例如
<div class="firstClass secondClass thirdclass fourthclass"></div>
继承不是CSS标准的一部分。
是的,但不完全符合该语法。
.composite,
.something { display:inline }
.composite,
.else { background:red }
链接地址: http://www.djcxy.com/p/22841.html