我长期以来一直是一名网络程序员并且不知道这个问题的答案我感到愚蠢,我实际上希望这是可能的,我只是不知道而不是我认为的答案(这是不可能的) .
我的问题是,是否有可能创建一个"继承"另一个CSS类(或多个)的CSS类.
例如,假设我们有:
.something { display:inline }
.else { background:red }
Run Code Online (Sandbox Code Playgroud)
我想做的是这样的事情:
.composite
{
.something;
.else
}
Run Code Online (Sandbox Code Playgroud)
其中".composite"类既显示内联又显示红色背景
我正在使用wordpress的根主题:https://github.com/retlehs/roots/
它已经预编译了bootstrap.css,并建议使用app.css进行任何自定义.由于我没有通过html或javascript将类添加到按钮的选项,我想使用LESS源来引用一个css类,例如,我想给一个提交按钮引导按钮样式:
input#submit{
.btn;
.btn-primary;
}
Run Code Online (Sandbox Code Playgroud)
如果我使用@import 'bootstrap.less';它将整个bootstrap css添加到app.css中.我怎样才能使用bootstrap.less作为编译参考?
在下面的代码中,有没有办法.center在CSS声明中使用该类而不是class=在每个div中执行一个?每个div应该有一个margin:0 auto.
CSS
.center {margin:0 auto;}
#first {width:400px; font-size:10px;}
#second{width:400px;text-align:center;}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="center" id="first">This is the first line</div>
<div id="second">This is the first line</div>
Run Code Online (Sandbox Code Playgroud)