是否可以创建一个“继承”自另一个(或多个)CSS 类的 CSS 类。
例如,假设我们有:
.something { display:inline }
.else { background:red }
我想做的是这样的:
.composite
{
.something;
.else
}
其中“.composite”类将内联显示并具有红色背景
最佳答案
有类似 LESS 的工具,它允许您在类似于您描述的更高抽象级别上编写 CSS。
Less 调用这些“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;
}
关于css - 一个 CSS 类可以继承一个或多个其他类吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31097072/