/// UPDATED SOLUTION DEMO 2 WATCH ////
I hope this is the solution you are looking for! DEMO1 DEMO2
With this solution, the only scroll bar on the page is in the middle of your content section! In this section, create your structure using the sidebar or whatever you want!
You can do this with this code here:
<div class="navTop"> <h1>Title</h1> <nav>Dynamic menu</nav> </div> <div class="container"> <section>THE CONTENTS GOES HERE</section> </div> <footer class="bottomFooter"> Footer </footer>
With this css:
.navTop{ width:100%; border:1px solid black; float:left; } .container{ width:100%; float:left; overflow:scroll; } .bottomFooter{ float:left; border:1px solid black; width:100%; }
And a bit of jquery:
$(document).ready(function() { function setHeight() { var top = $('.navTop').outerHeight(); var bottom = $('footer').outerHeight(); var totHeight = $(window).height(); $('section').css({ 'height': totHeight - top - bottom + 'px' }); } $(window).on('resize', function() { setHeight(); }); setHeight(); });
Demo 1
If you do not want jquery
<div class="row"> <h1>Title</h1> <nav>NAV</nav> </div> <div class="row container"> <div class="content"> <div class="sidebar"> SIDEBAR </div> <div class="contents"> CONTENTS </div> </div> <footer>Footer</footer> </div>
CSS
*{ margin:0;padding:0; } html,body{ height:100%; width:100%; } body{ display:table; } .row{ width: 100%; background: yellow; display:table-row; } .container{ background: pink; height:100%; } .content { display: block; overflow:auto; height:100%; padding-bottom: 40px; box-sizing: border-box; } footer{ position: fixed; bottom: 0; left: 0; background: yellow; height: 40px; line-height: 40px; width: 100%; text-align: center; } .sidebar{ float:left; background:green; height:100%; width:10%; } .contents{ float:left; background:red; height:100%; width:90%; overflow:auto; }
Demo 2
source share