This is a topic that comes up often when I’m doing web site design and I figured I’d throw it up here for my own reference. The challenge is to design a footer that will float to the bottom of the page regardless of the size of the content above it. Ryan’s excellent article on sticky footer’s is where I pulled 99% of this from. I made some minor tweaks to the CSS to suit my own needs but other than that, it’s not much different. Check out Ryan’s awesome article!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| <html>
<head>
<link rel="stylesheet" href="layout.css" ... />
</head>
<body>
<div class="wrapper">
<p>Your website content here.</p>
<div class="push"></div>
</div>
<div class="footer">
<p>Copyright (c) 2008</p>
</div>
</body>
</html> |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| <p>* {
margin: 0;
}
</p>
html, body
{
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -2em;
padding-left:2px;
padding-right:2px;
}
.footer {
height: 2em;
}
.footer p
{
font-family:Verdana;
font-size:9pt;
color:#696969;
font-weight:bold;
padding-top:10px;
padding-left:2px;
text-align:center;
}
.push
{
height: 2em;
} |