如何防止 Less 尝试编译 CSS calc() 属性? [英] How to prevent Less from trying to compile CSS calc() properties?

查看:37
本文介绍了如何防止 Less 尝试编译 CSS calc() 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的 Less 编译器(OrangeBitsdotless 1.3.0.5) 正在积极翻译

The Less compilers that I'm using (OrangeBits and dotless 1.3.0.5) are aggressively translating

body { width: calc(100% - 250px - 1.5em); }

进入

body { width: calc(-151.5%); }

这显然不是我们想要的.我想知道是否有办法向 Less 编译器发出信号,以便在编译期间基本上忽略该属性.我搜索了 Less 文档和两个编译器的文档,但找不到任何内容.

Which is obviously not desired. I'm wondering if there is a way to signal to the Less compiler to essentially ignore the attribute during compilation. I've searched through the Less documentation and both compilers' documentation, and I could not find anything.

Less 或 Less 编译器是否支持这一点?

Does Less or a Less compiler support this?

如果没有,是否有 CSS 扩展器可以实现?

If not, is there a CSS extender that does?

推荐答案

Less 默认不再计算 calc 中的表达式,因为 v3.00.

Less no longer evaluates expression inside calc by default since v3.00.

原始答案(Less v1.x...2.x):

这样做:

body { width: calc(~"100% - 250px - 1.5em"); }

在 Less 1.4.0 中,我们将有一个 strictMaths 选项,该选项要求所有 Less 计算都在括号内,因此 calc 将out-of-the-"盒子".这是一个选项,因为它是一个重大的突破性变化.默认情况下,1.4.0 的早期测试版启用了此选项.发布版本默认关闭.

In Less 1.4.0 we will have a strictMaths option which requires all Less calculations to be within brackets, so the calc will work "out-of-the-box". This is an option since it is a major breaking change. Early betas of 1.4.0 had this option on by default. The release version has it off by default.

这篇关于如何防止 Less 尝试编译 CSS calc() 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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