Sunday, April 3, 2011

Web page setup: Using Footers.


I have spent half the day trying to figure out how to get fixed-footers on web-pages I am making. I have something that works - up until the resolution is larger than my setup... if I fix it, I will update this. The general concensus for getting fixed position footers is to use the following CSS and HTML code for setting up your page template. Best done at the start in my opinion (You ARE planning your websites before you start coding aren't you? :) )

Some notes: no "margin x" commands can be used on the vertical axis as I understand it as it pushes the position of the following <div's> down so you end up with a scrollbar.

-----CSS-----
* {
     margin: 0px;
}
html, body {
     height: 100% ;
}
.mainwapper {
     min-height: 100%;
     height: auto ;
     height: 100%; /*These two set the containing div to the height of the browser window. All displayed div's are contained within.*/
     margin: 0 auto -2em; /*the 2em is height reserved for the footer. The footer is indented by this much to make it sit at the bottom of the page.*/
}
.footer, .push {
     height: 2em;
}

-----HTML-----
Div structure would be:

<html>
<head></head>
<body>
     <div id="mainwrapper">
          <div id="push"></div>
     </div>
     <div ="footer">
     </div>
</body>
</html>

Silly me - after writing this I now see where I went wrong setting mine up. Push is a div, hopefully when I tackle this again tomorrow I will get it working as expected. Im not much of a planner at the moment...

No comments:

Post a Comment