在 Less 中连接字符串 [英] Concatenate strings in Less

查看:32
本文介绍了在 Less 中连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是不可能的,但我想我会问以防万一.这个想法是我有一个用于网络资源文件夹路径的变量:

I think this is not possible, but I thought I ask in case there is a way. The idea is that I have a variable for path to web resource folder:

@root: "../img/";
@file: "test.css";
@url: @root@file;

.px {
    background-image: url(@url);
}

我得到了这个结果:

.px { background-image: url("../img/" "test.css"); }

但是,我希望这些字符串像这样组合成一个字符串:

But, I want the strings to combine into one string like this:

.px { background-image: url("../img/test.css"); }

是否可以在 Less 中将字符串连接在一起?

Is it possible to concatenate strings together in Less?

推荐答案

使用 变量插值:

@url: "@{root}@{file}";

完整代码:

@root: "../img/";
@file: "test.css";

@url: "@{root}@{file}";

.px{ background-image: url(@url); }

这篇关于在 Less 中连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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