Solution 1 :

Flexbox will allow you to solve this so long as your container has a set height somewhere.

.page {
  width: 100%;
  display: flex;
  height: 100vh;
  flex-direction: column;
  overflow: hidden;
}

.page-title,
.filters,
.action-buttons {
  width: 100%;
  flex: 0 0 auto;
}

.fill-until-scrollable {
  flex: 1 1 0;
  overflow: auto;
}

/* Just for the demo… delete these after */
.page { height: 40vh; /* I'm guessing 100vh in your case? */ }
.fill-until-scrollable table { display: block; height: 250vh; background: linear-gradient(00deg, grey, pink); }
<!-- site template content above -->
<div class="page" id="where the content is loaded for all pages">
  <div class="page-title"> <!-- Needs to stay at the top of the content box. SHOULD NOT vertically scroll out of view. -->
    Show a title, at the top of the page!
  </div>
  <div class="filters"> <!-- Should stay at the top, anchored below the Page Title div. -->
    <input type=text value="blah blah blah" />
    ...
  </div>
  <div class="fill-until-scrollable"> <!-- This needs to grow to fit (both x & y) as the browser window grows. -->
    <table> <!-- This table can have a lot of data. Assume it's height to be 100% of it's content, however, the fill-until-scrollable parent will need to have proper overflow/sizing CSS settings so that if the table data will be scrollable if it's to large for the window, without hiding the buttons below. -->
      ...
    </table>
  </div>
  <div class="action-buttons"> <!-- This needs to be the full width of the page, anchored at the bottom of the browser window. -->
    <button>Foo</button>
    <button>Bar</button>
  </div>
</div>
<!-- site template content below -->

Solution 2 :

It’s easy if all elements except .fill-until-scrollable have known height.

<style>
#container {
  position: relative;
  height: 100vh
}
#container > div {
  position: absolute;
  left: 0; right: 0;
  border: 1px solid #ccc
}
.page-title {
  top: 0;
  height: 100px;
}
.filters {
  top: 100px;
  height: 100px;
}
.fill-until-scrollable{
  overflow: auto; 
  top: 200px;
  bottom: 100px
}
.action-buttons {
  bottom: 0;
  height: 100px;
}
</style>

Solution 3 :

If the filter and button divs have fixed height, you can use calc() to set the height of the scrollable div like:

. fill-until-scrollable { height:calc(100% - 250px); overflow: auto;  }

Where 250px is the combined height of the other divs.

Problem :

I apologize because though I’m sure this has been asked, I cannot find a solution after considerable searching.

I have a table that may have a lot of data loaded into it. This table is housed within a content region that is part of a templated site, and within that content region there will be a title bar and a filter region above the table. Below the table a series of buttons. The table needs to grow to fill the window but both the buttons at the bottom of the page, and he header/filter information at the top of the page must always remain in the browser window.

The sample code below is a general outline of the HTML I’m working with. I have a title and filter divs that need to remain at the top of the content box, while the buttons at the bottom need to stay “anchored” at the bottom of the browser window.

The table (or it’s containing div) need to grow to fill all of the space in the middle, and scrollbars need to appear when the content is to big for the window in the middle of the content region.

<!-- site template content above -->
<div id="where the content is loaded for all pages">
  <div class="page-title"> <!-- Needs to stay at the top of the content box. SHOULD NOT vertically scroll out of view. -->
    Show a title, at the top of the page!
  </div>
  <div class="filters"> <!-- Should stay at the top, anchored below the Page Title div. -->
    <input type=text value="blah blah blah" />
    ...
  </div>
  <div class="fill-until-scrollable"> <!-- This needs to grow to fit (both x & y) as the browser window grows. -->
    <table> <!-- This table can have a lot of data. Assume it's height to be 100% of it's content, however, the fill-until-scrollable parent will need to have proper overflow/sizing CSS settings so that if the table data will be scrollable if it's to large for the window, without hiding the buttons below. -->
      ...
    </table>
  </div>
  <div class="action-buttons"> <!-- This needs to be the full width of the page, anchored at the bottom of the browser window. -->
    <button>Foo</button>
    <button>Bar</button>
  </div>
</div>
<!-- site template content below -->

I know this has to be a common need, but I can not find a way to do this. Any simple examples would be appreciated. Thank you.

Comments

Comment posted by chriskirknielsen

You’ll probably want to use flexbox, in a column direction. The top/bottom boxes should have

Comment posted by RLH

@chriskirknielsen I avoided mentioning any of my attempts because I’ve found that on SO, when you mention one approach, answers will try to follow your lead some time, rather than giving you the best solution, which might take a different approach. I’ve tried using flexbox settings but when I do, it ignores the overflow CSS and makes the table grow to the full height of the content. If I get rid of the flexbox properties, I have to set a fixed height on the scroll region, which means it won’t grow with the browser window.

Comment posted by Roman

The title, filters, and buttons have a fixed height?

Comment posted by RLH

@Roman yes, but some of the parts might be shown/hidden, depending on context. They are fixed in size, though.

Comment posted by chriskirknielsen

@RLH Sure but now we have to assume things about your project if you don’t share your code… Anyway, see my answer. Should get you there.

Comment posted by RLH

This

Comment posted by TinMonkey

calc() usually works ok in IE11 for simple operations, it starts to crap out with nested operations, transitions or dynamically generated content. Good Luck!

By