1

I am trying this:

.main{
            min-height: -moz-calc(100% -50px);
      min-height: -webkit-calc(100% -50px);
      min-height: calc(100% -50px);
   background-color:#000;
   color:white;
    }

html{
height:100%;
}
<html>
<body style='height:100%;'>
      <header style='height:50px;background-color:#0e0'></header>
      <div class="main">ok</div>
    </body>
  </html>

But it doesn't work

I want my div to go to the bottom of screen minus the header that is 50px

Thanks

lopata
  • 1,325
  • 1
  • 10
  • 23

1 Answers1

1

height: 100% can work if all ancestors of .main have the same height defined but in your example the html element has not defined any height.

Example #1 (height set on html element): http://codepen.io/anon/pen/bdrYqx


You could try also vh units: this won't require to set the height also on the ancestors

.main{
    min-height: -moz-calc(100vh - 50px);
    min-height: -webkit-calc(100vh - 50px);
    min-height: calc(100vh - 50px);
}

Example #2: (no height, only vh unit): http://codepen.io/anon/pen/pJrdeB

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177