gpt4 book ai didi

css - 在 LESS 中,我如何将返回值混合到类集合中

转载 作者:行者123 更新时间:2023-11-28 13:14:06 24 4
gpt4 key购买 nike

例如,假设我有以下内容:

.document {
header {
color: blue;
}
footer {
color: red
}
}

期望的结果:

.my_document {
.document;
}

这样的.document;替换为

header {
color: blue;
}
footer {
color: red;
}

最佳答案

来自 http://lesscss.org :

You can also use parametric mixins which don’t take parameters. This is useful if you want to hide the ruleset from the CSS output, but want to include its properties in other rulesets:

.wrap () {   
text-wrap: wrap;
white-space: pre-wrap;
white-space:
-moz-pre-wrap; word-wrap: break-word;
}

pre { .wrap }

所以在你的情况下使用:

.document() {
header {
color: blue;
}
footer {
color: red
}
}
.my_document {
.document;
}

(尝试在 http://less2css.org 中运行上面的代码)


我不太确定,但我认为在旧版本的 LESS 中,你必须像这样用括号调用这些混入

.my_document {
.document();
}

关于css - 在 LESS 中,我如何将返回值混合到类集合中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18179271/

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