css - 使用 Less 时在 CSS 值中斜线 (`/` )(例如在 `font` 简写中)

标签 css less

我注意到在使用 Less 和字体简写时出现问题

.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;

当我拆分属性时它起作用了

.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;

我认为这是因为斜杠/那导致了问题,我认为因为 Less 可以进行计算,例如。 2px + 5 = 7px 它试图做一个划分?

最佳答案

刚遇到这个问题,转义函数(无论如何对于 less.js)是: e() 像这样

font: @weight @size e('/') @height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif;

关于css - 使用 Less 时在 CSS 值中斜线 (`/` )(例如在 `font` 简写中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40240103/

相关文章:

CSS Less Reference Mixin中的伪元素

css - 我想在 Bootstrap 3 更改屏幕大小时更改背景颜色

CSS LESS 占位符混合

html - 在页面上定位元素

javascript - 需要一些帮助从谷歌地图 API 生成屏幕截图

css - 如何在图像代码中放置超链接?

css - 覆盖 Twitter Bootstrap Less 不起作用,添加新东西确实有效

javascript - 如何制作一个 'forward' 按钮

javascript - 如何在绿色 div 中启用文本选择?

css - 使用 less 和 Twitter bootstrap