CSS类可以继承一个或多个其他类吗?

梦想与她 提交于 2020-08-18 20:48:55

问题:

I feel dumb for having been a web programmer for so long and not knowing the answer to this question, I actually hope it's possible and I just didn't know about rather than what I think is the answer (which is that it's not possible). 我作为一个网络程序员已经这么长时间了,而且不知道这个问题的答案,这让我感到很愚蠢。我实际上希望这是可能的,我只是不知道答案,而不是我认为答案是什么(那是不可能的) 。

My question is whether it is possible to make a CSS class that "inherits" from another CSS class (or more than one). 我的问题是,是否有可能使一个CSS类从另一个CSS类(或多个CSS类)“继承”。

For example, say we had: 例如,假设我们有:

.something { display:inline }
.else      { background:red }

What I'd like to do is something like this: 我想做的是这样的:

.composite 
{
   .something;
   .else
}

where the ".composite" class would both display inline and have a red background 其中“ .composite”类将同时显示内联并具有红色背景


解决方案:

参考一: https://stackoom.com/question/4TAR/CSS类可以继承一个或多个其他类吗
参考二: https://oldbug.net/q/4TAR/Can-a-CSS-class-inherit-one-or-more-other-classes
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!