在 less css 中转义整个声明

发布于 2024-12-18 10:14:59 字数 198 浏览 6 评论 0原文

是否有可能逃脱整个声明? 这在 less.js 中符合要求(我正在使用 less.app),

margin: e(" 0 10px");

但这会引发错误:

e("margin: 0 10px");

我尝试将“margin”放入变量中,但没有成功。

Is it possible to escape whole declaration?
This complies fine in less.js (I'm using less.app)

margin: e(" 0 10px");

But this throws an error:

e("margin: 0 10px");

I've tried putting 'margin' in a variable but without success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满天都是小星星 2024-12-25 10:15:00

抱歉,这是不可能的。但有几点:

官方转义名称(根据 lesscss.org 是波形符引号,而不是 e () 语法,如下所示:

margin: ~"0 10px";

其次,您提供的代码不够复杂,无法保证 LESS CSS 字符串文字。请分享您遇到问题的实际代码。可能想结束这个问题并询问另一个问题。

第三,请记住,您可以包含 .css 文件 - 它不会被编译,只是转储到输出中。语法与标准 CSS 导入相同:

@import "myfile.css";

Sorry that's not possible. A couple things though:

The official escape designation (according to lesscss.org is the tilde-quote, not the e() syntax, like so:

margin: ~"0 10px";

Second, the code you provided is not nearly complex enough to warrant a LESS CSS string literal. Please share the actual code that you are having trouble with. You may want to close this question and ask another one.

Third, remember that you can include a .css file - it will not be compiled, just dumped into the output. The syntax is identical to a standard CSS import:

@import "myfile.css";
执笏见 2024-12-25 10:15:00

经过多次尝试,我将其编译并输出到我的 less 文件中。

font-family: e("'object-fit: contain;'");

这是 IE object-fit 的一个 hack(我从 object-fit

After many attempts, I got this to compile and output in my less file.

font-family: e("'object-fit: contain;'");

This is a hack for IE object-fit (I got that idea from object-fit

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文