Last active
January 13, 2016 00:06
-
-
Save ryzr/3434c650e517c7c0f50c to your computer and use it in GitHub Desktop.
Content + sidebar with equal height at least as tall as window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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