Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use vh minus pixels in a CSS calc()? [duplicate]

Tags:

css

less

People also ask

What is VH PX in CSS?

px – It defines the font-size in terms of pixels. ( 96px = 1in) vh – Relative to 1% of the height of the viewport. vw – Relative to 1% of the width of the viewport.

What is Calc function in CSS?

calc() The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a <length> , <frequency> , <angle> , <time> , <percentage> , <number> , or <integer> is allowed.

What is the VH in CSS?

The full form of VH is viewport height.

What is Calc 100vh 100px?

Yes: #specificElement { height: calc(100vh - 100px); box-sizing: border-box; } This uses the CSS calc() function to subtract 100px from 100vh ( 1vh being one percent of the view-port's height) and uses the result as the value of the height property.


It does work indeed. Issue was with my less compiler. It was compiled in to:

.container {
  min-height: calc(-51vh);
}

Fixed with the following code in less file:

.container {
  min-height: calc(~"100vh - 150px");
}

Thanks to this link: Less Aggressive Compilation with CSS3 calc