Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
Created November 16, 2016 11:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodneyrehm/7ea1fff59a0d5663539bd74ed3976e50 to your computer and use it in GitHub Desktop.
Save rodneyrehm/7ea1fff59a0d5663539bd74ed3976e50 to your computer and use it in GitHub Desktop.
CSS: full height column, allowing fixed-height header and footer and scrollable content
/*
<article class="full-height-column">
<header></header>
<section></section>
<footer></footer>
</article>
*/
.full-height-column {
display: flex;
flex-direction: column;
/*
IE11 does not like auto, but works fine with 100%
*/
flex: 1 1 100%;
/*
Firefox get's freaky with nested overflow containers
see https://lists.w3.org/Archives/Public/www-style/2014Jul/0589.html
*/
min-width: 0;
}
.full-height-column > header,
.full-height-column > section,
.full-height-colum > footer {
box-sizing: border-box;
}
.full-height-column > section {
/*
make the element stretch to fill the available space
see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis
*/
flex: 1 1 100px;
/*
make the element scrollable
see http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/
*/
overflow-x: hidden;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
/*
make sure the scrollbar is drawn on top of the content
see http://stackoverflow.com/questions/15152470/chrome-rendering-issue-fixed-position-anchor-with-ul-in-body/15203880#15203880
*/
transform: translateZ(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment