1

I am working on webpage which has 2 main rows, the top row has a fixed height of say 300px and does not change.

The bottom row needs to fill the height of the viewport/screen (the rest if the averrable space.)

Please see this wireframe as basic example: https://wireframe.cc/aUePUH

I have tried setting the body/html to 100% then the bottom row container to 100% making the 3 cols in that bottom row 100% height too but they only seem to go to 100% height of the content.

ideally I would like to set a minimum height on the bottom row and then for it to just expand and fill the viewport if more vertical space is available

I also ha d ago with height: 100vh but that didn't seem to do it.

<div class="container">
  <div class="row top-row">
    <p>Top Row with a fixed heigh - 300px</p>
  </div>

  <div class="row bottom-row">
    <div class="col-xs-4">
      <p>Col 1</p>
      <p>
        Should fill viewport/avaialable screen height
      </p>
    </div>

    <div class="col-xs-4">
      <p>Col 2</p>
      <p>
        Should fill viewport/avaialable screen height
      </p>
    </div>

    <div class="col-xs-4">
      <p>Col 3</p>
      <p>
        Should fill viewport/avaialable screen height
      </p>
    </div>
  </div>
</div>

top-row {
  height: 300px;
  background-color: black;
  color: white;
  margin-bottom: 15px;
}

.bottom-row {
  height: 100%;
}

.col-xs-4 {
  background-color: red;
  color: white;
}

Here is a JS FIDDLE example: https://jsfiddle.net/DTcHh/16054/

chinds
  • 1,761
  • 4
  • 28
  • 54
  • Possible duplicate of [Make a div fill the height of the remaining screen space](http://stackoverflow.com/questions/90178/make-a-div-fill-the-height-of-the-remaining-screen-space) – Rob Jan 18 '16 at 15:56

2 Answers2

5

Here's a solution using height:calc(); https://jsfiddle.net/DTcHh/16058/

It was kind of hard to set due to your body padding but it works.

.bottom-row {
  height:calc(100vh - 335px);
}

.col-xs-4 {
  height:100%;
  background-color: red;
  color: white;
}
fnune
  • 5,256
  • 1
  • 21
  • 35
1

You can try using flexbox. It should be able to trigger the scrollbar correctly on smaller viewport height.

body {
  margin: 0;
}
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.top-row {
  flex: 0 0 300px;
  background-color: black;
  color: white;
  margin-bottom: 15px;
}
.bottom-row {
  flex: 1;
  background-color: red;
  color: white;
}

https://jsfiddle.net/3kom9Lo6/

Stickers
  • 75,527
  • 23
  • 147
  • 186