203

I have following CSS rule in a Less file:

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

Which doesn't work at all. I want to make container full window height and minus header, footer fixed height.

How can I do that?

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Alexander Kim
  • 17,304
  • 23
  • 100
  • 157
  • 2
    Seems to work - http://jsfiddle.net/gz4zp1ua/2/ – Paulie_D Dec 02 '14 at 19:29
  • 1
    Make sure the browser in question actually supports what you're asking for: http://caniuse.com/#feat=calc and http://caniuse.com/#feat=viewport-units. – cimmanon Dec 02 '14 at 19:43
  • I had closed this as a dupe because that thread has details about updated options also which could be useful for others (on top of it, that question also has higher views and vote counts). – Harry Dec 04 '15 at 13:48
  • If you're using less variables you can use something like this: calc(~"100vh" - (**@first-header-height** + **@second-header-height**)); – Hamid Behnam Mar 28 '16 at 20:59

1 Answers1

287

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

Community
  • 1
  • 1
Alexander Kim
  • 17,304
  • 23
  • 100
  • 157