连接字符串和var少css [英] Concatenate string and var less css

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

问题描述

任何人都可以告诉我如何在LESS中连接一个var和一个字符串,所以我之间没有空格?

Can anyone please tell me how to concatenate a var and a string in LESS so I don't have the space between them?

我有以下代码:

.text(@size) {
    font-size: @size + px;
    line-height: (@size / 10) + em;
}

h1 {
   .text(16)
}

LESS的输出如下:

What the LESS outputs is the following:

h1 {
    font-size: 12 px;
    line-height: 1.2 em;
}

我需要找到一种删除空格的方法。

I need to find a way to remove the spaces.

感谢
Pete

Thanks Pete

推荐答案

这里有一个内置函数:

unit(@dimension, [@unit: ""]);

因此 font-size:unit(@size,px) code>会导致 font-size:12px 。我测试了它。

http://lesscss.org/#reference

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

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