gpt4 book ai didi

less - 如何使用 LESS 合并父子样式属性

转载 作者:行者123 更新时间:2023-12-02 06:56:32 27 4
gpt4 key购买 nike

我有这个更少的代码,这工作得很好。我只是想在 less cli 编译它时节省一些空间。

.secondary-content {
background: #ffcc80;
color: white !important;

label, i {
background: #ffcc80;
color: white !important;
}
}

当我从命令提示符运行 less 时,输出如下所示。
.secondary-content {
background: #ffcc80;
color: white !important;
}
.secondary-content label,
.secondary-content i {
background: #ffcc80;
color: white !important;
}

如您所见,它们在每个块上都是分​​开的。我想让他们在同一个街区。如何轻松合并父和子样式属性?像这样。
.secondary-content,
.secondary-content label,
.secondary-content i {
background: #ffcc80;
color: white !important;
}

我仍然学得更少,所以任何帮助将不胜感激。

提前致谢

最佳答案

您可以使用 parent selector ( & ) 就像下面的代码片段。使用父选择器意味着同样的规则适用于 .ghost .secondary-content选择器及其子级 labeli标签。

.ghost .secondary-content {
&, label, i {
background: #ffcc80;
color: white !important;
}
}

关于less - 如何使用 LESS 合并父子样式属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30299289/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com