CSS类可以继承一个或多个其他类吗?我觉得自己很傻,因为我做了这么长时间的网络程序员,却不知道这个问题的答案,我实际上希望这是可能的,我只是不知道,而不是我认为答案是什么(这是不可能的)。我的问题是,是否可以创建一个从另一个CSS类(或多个CSS类)“继承”的CSS类。例如,假设我们有:.something { display:inline }.else { background:red }我想做的是这样的事情:.composite
{
.something;
.else}其中,“.复合”类将同时显示内联并具有红色背景。
3 回答

拉丁的传说
TA贡献1789条经验 获得超8个赞
/* 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;}

噜噜哒
TA贡献1784条经验 获得超7个赞
<div class="firstClass secondClass thirdclass fourthclass"></div>

胡子哥哥
TA贡献1825条经验 获得超6个赞
.composite,.something { display:inline }.composite,.else { background:red }
- 3 回答
- 0 关注
- 905 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消