Search code examples
cssheaderresponsive-designfootersticky

CSS Sticky Header/Footer and Fully Stretched Middle Area?


With CSS, how can i simply get a page with sticky header and footer which are appearing forever, whenever the page is scrolling or not. I found some sample online, but what i additional want is, the middle content area should be a 100% stretched area between header and footer whatever the browser size is.

I mean, most of the Samples i found, are making Header and Footer sticky correctly.., but these are just floating and actually covering the Top and Bottom parts of the 'middle' content area. That's not what i really want.

enter image description here


Solution

  • Can use absolute position for all 3 elements.

    #header,#footer,#content { position:absolute; right:0;left:0}
    
    #header{
       height:100px; top:0;
    }
    #footer{
      height:100px; bottom:0;
    }
    #content{
      top:100px;
      bottom:100px;
      overflow:hidden; /* use this if don't want any window scrollbars and use an inner element for scrolling*/
    }
    

    DEMO: http://jsfiddle.net/RkX8B/