本文介绍了使用Less时,CSS值中的斜杠(`/`)(例如,在`font`简写中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到使用Less与字体缩写时出现的问题
i noticed an issue when using Less with font shorthand
.font(@weight: 300, @size: 22px, @height: 32px) {
font: @weight @size/@height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
}
上述操作失败,
this.a.toCSS is not a function
http://localhost/tumblr/modern1/css/style.less on line 1, column 0:
1. @highlight: #cb1e16;
2. @shade1: #cb1e16;
当我拆分属性时,它工作
when i split the properties up it works
.font(@weight: 300, @size: 22px, @height: 32px) {
font-weight: @weight;
font-size: @size;
line-height: @height;
font-family: "Yanone Kaffeesatz", "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
}
slash / thats导致的问题,我认为,Less可以做计算,例如。 2px + 5 = 7px
它试图做一个除法?
i think its because of the slash / thats causing the problem, i think since Less can do calculations, eg. 2px + 5 = 7px
its trying to do a divide?
推荐答案
刚刚碰到这个问题,转义函数(对于less.js反正)是:
e()
像这样
Just ran into this issue, the escape function (for less.js anyway) is: e()Like this
font: @weight @size e('/') @height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;
这篇关于使用Less时,CSS值中的斜杠(`/`)(例如,在`font`简写中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!