使用LESS时,如何在已编译的CSS文件中保留重复属性? [英] How to keep duplicate properties in compiled CSS file when use LESS?

查看:43
本文介绍了使用LESS时,如何在已编译的CSS文件中保留重复属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无需验证码

.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆