css - 使用带有 LESS 的原生 CSS 最小/最大函数
问题描述
我想将 min() CSS 函数与用 LESS 编写的样式表一起使用。但是,LESS 有自己的 min 和 max 函数,可以预先计算值(使得混合和匹配单元成为不可能)。我如何获得它,以便输出 CSS 在我编写它们时具有最小/最大功能?
这是LESS文件中的样式,也应该是预期的输出。
canvas {
background: white;
width: min(95vh, 95vw);
height: min(95vh, 95vw);
}
我正在使用 lessc 3.13.1,它会产生以下错误:
ArgumentError: error evaluating function `min`: incompatible types in <snipped> on line 49, column 12:
48 background: white;
49 width: min(95vh, 95vw);
50 height: min(95vh, 95vw);
解决方案
Use LESS' string escaping capabilities to pass along a plain string to the CSS.
canvas {
background: white;
width: ~"min(95vh, 95vw)";
height: ~"min(95vh, 95vw)";
}
More info
https://github.com/less/less.js/issues/3463
body {
background: black;
}
canvas {
background: white;
width: ~"min(95vh, 95vw)";
height: ~"min(95vh, 95vw)";
}
<canvas></canvas>
推荐阅读
- c++ - 调试BFS,计算直到所有橘子都烂掉的最短时间
- firebase - 如何以最少的小部件重新构建和 Firestore 读取来使用 StreamProvider?
- python - Django session deletion effects another django application
- google-chrome - chrome的书签栏下出现黑色边框?
- slack - How might I share a message URL that renders a preview the same way Slack does?
- jquery - 提交表单时如何禁用必需的属性
- javascript - 在 puppeteer 中等待 page.waitFor inside page.evaluate?
- php - 检查是否使用 mysql 变量设置了 $_POST 变量
- excel - 如果多个单元格值为 True,则显示文本
- javascript - How do I add css class names to text blocks in Squarespace?