我在使用 Less CSS 方面还是新手,我找不到解决问题的方法。我想要一个更有效的输出结果。
我有这个代码少:
.btn-trans {
color: inherit;
background-color: transparent;
transition: all .4s;
&.btn-default {
color: @trans-default;
&:hover {
color: @trans-hover-color;
}
}
&.btn-primary {
color: @trans-primary;
&:hover {
color: @trans-hover-color;
}
}
}
这是css输出:
.btn-trans {
color: inherit;
background-color: transparent;
transition: all .4s;
}
.btn-trans.btn-default {
color: #bdbdbd;
}
.btn-trans.btn-default:hover {
color: #f5f5f5;
}
.btn-trans.btn-primary {
color: #738ffe;
}
.btn-trans.btn-primary:hover {
color: #f5f5f5;
}
但我正在寻找的结果是这样的:
.btn-trans {
color: inherit;
background-color: transparent;
transition: all .4s;
}
.btn-trans.btn-default {
color: #bdbdbd;
}
.btn-trans.btn-primary {
color: #738ffe;
}
.btn-trans.btn-default:hover,
.btn-trans.btn-primary:hover {
color: #f5f5f5;
}
由于颜色相同,因此嵌套了悬停类。