6

I have the following styling in my _main.less file

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

But the Less compiler complains (using 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.

But this works fine in CSS (see docs).

0

1 Answer 1

12
+200

Refer to Disable LESS-CSS Overwriting calc(), you can use escape string in LessCSS:

#mapid {
    width: 100%;
    min-height: ~"min(65vh, 500px)";
    max-height: 500px;
}
Sign up to request clarification or add additional context in comments.

4 Comments

It works for me for calc() calls, but not for min() - still getting ActionView::Template::Error: Incompatible units: '%' and 'px'.
@Trung0246, calc(max(1vw, 2px)) doesn’t work for me. Note that your link refers to Sass, but the question refers to Less.
Brilliant! this did the trick for me!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.