-1
height: calc(100% + 60px);

Above code will failed, any clue how to add extra 60px to a height of 100% using LESS?

Alan Jenshen
  • 3,159
  • 9
  • 22
  • 35

2 Answers2

1

The height in percentage does not work properly every time. It will work fine if your parent have fix height (either in px, pt, view port unit).

Its better to use view port for height. If you are not aware of it, read the following article.

https://css-tricks.com/viewport-sized-typography/

https://www.w3schools.com/cssref/css_units.asp

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
Shubham
  • 285
  • 2
  • 15
1

LESS and CSS have a calc function. If you want to use the CSS calc function instead of LESS's, then you need to escape your equation. Like so:

height: calc(~"100% + 60px");

You can still pass LESS variables into this calc call. You need to encapsulate your variable with brackets though. Like so:

@padding-variable: 60px;

height: calc(~"100% + @{padding-variable}");
Graham
  • 7,431
  • 18
  • 59
  • 84
Hynes
  • 3,394
  • 3
  • 22
  • 22