【问题标题】:Less.js: error evaluating function `min`: incompatible types [duplicate]Less.js:错误评估函数`min`:不兼容的类型[重复]
【发布时间】:2020-10-08 03:51:15
【问题描述】:

我的_main.less 文件中有以下样式

#mapid {
  width: 100%;
  min-height: min(65vh, 500px);
  max-height: 500px;
}

但是 Less 编译器会抱怨(使用 grunt)

>> File "public/less/_main.less" changed.
Running "less:development" (less) task
>> ./public/less/_main.less: [L86:C14] error evaluating function `min`: incompatible types
Warning: Error compiling ./public/less/_main.less Use --force to continue.

Aborted due to warnings.

但这在 CSS (see docs) 中运行良好。

【问题讨论】:

    标签: css gruntjs less


    【解决方案1】:

    参考Disable LESS-CSS Overwriting calc(),可以在LessCSS中使用转义字符串:

    #mapid {
        width: 100%;
        min-height: ~"min(65vh, 500px)";
        max-height: 500px;
    }
    

    【讨论】:

    • 它适用于calc() 呼叫,但不适用于min() - 仍然得到ActionView::Template::Error: Incompatible units: '%' and 'px'.
    • @Trung0246, calc(max(1vw, 2px)) 不适合我。请注意,您的链接指的是 Sass,但问题指的是 Less。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2018-03-04
    • 1970-01-01
    • 2021-03-13
    相关资源
    最近更新 更多