Skip to content

Instantly share code, notes, and snippets.

@ryzr
Last active January 13, 2016 00:06
Show Gist options
  • Save ryzr/3434c650e517c7c0f50c to your computer and use it in GitHub Desktop.
Save ryzr/3434c650e517c7c0f50c to your computer and use it in GitHub Desktop.
Content + sidebar with equal height at least as tall as window
<style>
.wrapper {
position: relative;
}
.sidebar, .content {
min-height: 100%;
}
</style>
<div class="wrapper">
<div class="sidebar">
</div>
<div class="content">
</div>
</div>
<script>
$(document).on('ready', function(){
$(window).on('resize', adaptContentAndSidebar);
adaptContentAndSidebar();
});
function adaptContentAndSidebar() {
var page_height = $(window).height(); - negate header/footer/other heights here if necessary
var wrapper = $('.wrapper').css('min-height', 'auto');
var sidebar = $('.wrapper > .sidebar');
wrapper.css('min-height', Math.max(page_height, sidebar.outerHeight()));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment