You didn’t provide html so I’m going to have to guess a little.
Assuming your footer is inside #wrapper then all you need do is change bottom:0 to bottom:5px (or whatever gap you want). If you also want a gap at the side then do this:
The width is removed and the element placed 5px from the left and right instead.
You will also need to increase the padding-bottom on #main to make room for the gap you added.
#main {padding-bottom:60px;}
Take a look at the CSS faq on the sticky footer to see more robust methods of creating a sticky footer as your method will not cater for text resize (or for a fluid height sticky footer) although you could set the footer height n ems to cater for a simple text resize.
Maybe this will help. It’s a modern example of a sticky footer with a gap all around the main section.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Sticky footer IE8+</title>
<style type="text/css">
/* use border-box model */
*,*:after,*:before{
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
-ms-box-sizing:border-box;
box-sizing:border-box;
}
html, body {
margin:0;
padding:0;
height:100%;
}
body{background:red;}
#wrap {
display:table;
max-width:1000px;
margin:0 auto;
height:100%;
border-top:10px solid transparent;
border-bottom:10px solid transparent;
}
*+html #wrap{height:auto}/* ie7*/
.content { background:#ccc; }
header {
background:#999;
color:#fff;
text-align:center;
padding:10px 0
}
header, .footer, main { display:block }/* ie7 and under */
header, .footer, main { display:table-row }
/* height 1px on the header and footer is the sticky footer technique */
header, .footer { height:1px }
*+html header,*+html .footer{height:auto}/* ie7*/
h1 {
padding:10px;
margin:0;
}
.footer {
background:#999;
color:#fff;
text-align:center;
}
.footer p {
margin:0;
padding:10px
}
</style>
<!-- html5 shiv for IE8 and under -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="wrap">
<header>
<h1>Fluid Height Sticky footer simple - IE8+ only </h1>
</header>
<main class="content">Content</main>
<footer class="footer">
<p>Sticky footer</p>
</footer>
</div>
</body>
</html>
It’s a sticky footer in IE8+ but should just revert to a normal layout in ie7 and under (with a few tweaks).
The benefit of this layout is that you don;t need to compensate for the sticky footer in any way and it can contain as much or as little content as you need and will adapt to smaller layouts so is good for responsive design
Z-index deals with overlapping elements and applies only to positioned elements so would have no meaning on the body element or on #main. It should not be necessary at all in the example above anyway as the footer will never overlap the content in #wrapper anyway due to the padding on #main protecting the footer.
I put padding-bottom on the “wrapper” but it is moving the “footer” down as if the “footer” is outside the “wrapper” when it isn’t.
#wrapper is min-height:100% and if you add padding-bottom to it then it is now taller than the viewport by the amount of padding you added and therefore below the fold. As you are placing your footer at the absolute bottom of #wrapper then it too will start below the fold.
daniel3, if you would like to prepare a stand-alone page that demonstrates the problem, or post a link to your page, we can give better help.
If you were feeling ill and sent your doctor a message saying that you were feeling ill and asking him what is wrong with you, do you think he would know without examining you? That’s what you are asking us to do without seeing the code that shows the problem. We need to see your code in order to provide useful help.
Well the best solution is the one I already posted in #post#7 and does exactly what you want and in the most robust way. I’m not sure what you don’t like about it unless you are supporting ie7 and under?
There are other ways but none are as efficient and as foolproof as the method I gave as it does not rely on fixed heights or pushers or padding.
You can do it with code similar to yours using the border-box model again and you would do it like this:
The code in post #11 is basically the same length as yours but with the border-box rule added so that we can get a proper transparent gap.
Note that the absolute footer method will break if a user resizes their text unlike the method I recommend. These days users are more savvy and often resize text through their browser controls (especially when you get to my age as the eyes are the first thing to go :)).
I like to keep my code as short as possible and know what each bit does.