使用LESS时,如何在已编译的CSS文件中保留重复属性? [英] How to keep duplicate properties in compiled CSS file when use LESS?
问题描述
无需验证码
.foo {
background-size: 200px; //for old browsers
background-size: cover;
}
需要CSS
.foo {
background-size: 200px;
background-size: cover;
}
但是less.js会删除已编译CSS文件中的第一个background-size
属性.
but less.js remove the first background-size
property in compiled CSS file.
推荐答案
@ seven-phases-max clean-css
指出的AS将删除这些属性.
AS already pointed out by @seven-phases-max clean-css
removes these properties.
<罢工>
请注意,默认情况下已设置--advanced
.您应该使用--skip-advanced
选项来防止删除双重属性.
Notice that the --advanced
has been set by default. You should use the --skip-advanced
option to prevent your double properties from being removed.
根据 https://github.com/less/less-plugin-clean- css advanced
选项默认情况下设置为false.
According to https://github.com/less/less-plugin-clean-css the advanced
option has been set to false by default.
lessc foo.less
输出:
.foo {
background-size: 200px;
background-size: cover;
}
lessc --clean-css foo.less
输出:
.foo{background-size:200px;background-size:cover}
lessc --clean-css="advanced" foo.less
输出:
.foo{background-size:cover}
或者,您可以运行lessc -x foo.less
,它还会输出:
Alternatively you could run lessc -x foo.less
which also outputs:
.foo{background-size:200px;background-size:cover}
这篇关于使用LESS时,如何在已编译的CSS文件中保留重复属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!