Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header and footer with fixed position while content is scrollable?

I'm trying to make a website where header and footer have fixed position while content scrolls in the middle.

<header style="position:fixed"></header>
<div id="content">some content</div>
<footer style="position:fixed"></footer>

I created what I thought would work but it doesn't. Here's jsFiddle with the whole thing. As you can see, part of content is hidden under the footer and beyond (I can't see 'HELLOWEEN' in the end). What must I change to fix it? Thanx

like image 868
Michal Artazov Avatar asked Aug 13 '13 17:08

Michal Artazov


1 Answers

The easiest fix for this is to add padding equivalent to the height of your static header and footer:

#content {
    width: 80%;
    margin: 0 auto;
    padding: 60px 0;
}

JSfiddle

like image 173
Nick Tomlin Avatar answered Oct 24 '22 13:10

Nick Tomlin