zimmo Posted June 10, 2010 Share Posted June 10, 2010 I am getting better with css but this issue is driving me mad, i have a nice simple layout, and have the footer so its always where it should be. But as soon as i try and have a two column layout in the middle it stops the footer being where it should and is only positioned in the actual window so when you scroll it does not stay at the footer. Here is the html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Site</title> <link rel="stylesheet" type="text/css" href="../html/driving.css" /> </head> <body> <div id="container"> <!-- Header Starts Here --> <div id="header"> <img src="../html/images/logo.gif" width="480" height="180" alt="Crafty Cakes" style="vertical-align:top"/> </div> <!-- Content Holder Starts Here --> <div id="content"> <div class="left"> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> <div class="right"> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> </div> <!-- Footer Spacer Here --> <div id="spacer"> </div> <!-- Footer Starts Here --> <div id="footercontainer"> <div class="footer"> <ul> <li><a href="#">Link</a></li> </ul> <p><a href="#">Terms and Conditions</a></p> </div> </div> </div> </body> </html> And here is the css: /* CSS Style sheet */ html,body { margin:0; padding:0; height:100%; /* needed for container min-height */ font-family:arial,sans-serif; font-size:small; color:#666; } h1 { font:1.5em georgia,serif; margin:0.5em 0; } h2 { font:1.25em georgia,serif; margin:0 0 0.5em; } h1, h2, a { color:orange; } p { line-height:1.5; margin:0 0 1em; } div#container { position:relative; /* needed for footer positioning*/ margin:0 auto; /* center, not in IE5 */ width:100%; background-color: #ffffff; background-image: url(inc/mainbackground.gif); background-repeat: repeat-x; background-position: center top; height:auto !important; /* real browsers */ height:100%; /* IE6: treaded as min-height*/ min-height:100%; /* real browsers */ } div#header { position:relative; /* needed for footer positioning*/ width:1024px; height: 230px; margin:0 auto; /* center, not in IE5 */ } div#header p { font-style:italic; font-size:1.1em; margin:0; } div#content { position:relative; /* needed for footer positioning*/ width:1024px; margin:0 auto; /* center, not in IE5 */ padding:1em 1em 5em; /* bottom padding for footer */ height:100%; } div#content p { text-align:justify; padding:0 1em; } .left { position:relative; /* needed for footer positioning*/ width: 200px; float: left; } .right { position:relative; /* needed for footer positioning*/ width: 700px; float: right; } /* FOOTER */ div#footercontainer { position:absolute; width:100%; height: 100px; bottom:0; /* stick to bottom */ background-image: url(inc/footercontainer.gif); background-repeat: repeat-x; background-position: left top; } .footer { position:relative; /* needed for footer positioning*/ margin:0 auto; /* center, not in IE5 */ width:1024px; height: 100px; font: 12px Lucida Grande, Tahoma, sans-serif; color: #ffffff; background-image: url(inc/footer.gif); background-repeat: no-repeat; background-position: center top; } .footer ul { list-style: none; padding: 0; margin: 0; line-height: 40px; } .footer li { display: inline; margin: 0px; margin: 0; padding: 10px 10px 0px 10px; } .footer li a { text-decoration: none; color: #ffffff; } .footer li a:hover { color: #000000; } .footer p { padding: 0px 10px 0px 10px; } .footer p a { text-decoration: none; color: #ffffff; } .footer p a:hover { color: #000000; } /* END footer */ I have tried all sorts, but it just will not work. The content div holds these columns as div classes. If I take the classes out and have the content div for content it works fine. Someone said the following to me: "I copied your code into dreamweaver and had a look. I notice both your div's you're floating, left and right. When you float and element it is removed from the document flow and doesn't take up any space, and because of that, doesn't force the footer down to where you would probably like it. In a situation like this I would only float the smaller div, and position relative the other one where I want it. Does this help/make sence?" But I am not sure which to change? Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/ Share on other sites More sharing options...
haku Posted June 10, 2010 Share Posted June 10, 2010 You have to move it out of #container. Absolutely positioned elements are positioned absolutely within the first parent element that has relative or absolute positioning. If none exist (default), they are positioned absolutely to the body. But in your case, #container is positioned relatively. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070313 Share on other sites More sharing options...
zimmo Posted June 10, 2010 Author Share Posted June 10, 2010 How would I change this then, or what should I have on the style sheet for this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070320 Share on other sites More sharing options...
haku Posted June 10, 2010 Share Posted June 10, 2010 I told you how to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070323 Share on other sites More sharing options...
zimmo Posted June 10, 2010 Author Share Posted June 10, 2010 Sorry I am not an expert in css, still on the learning curve. So if I place this outside of the container: <div class="left"> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> And would I change the css to be absolute positioning? or just to float? Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070330 Share on other sites More sharing options...
haku Posted June 10, 2010 Share Posted June 10, 2010 I don't know where you got that from - you are having troubles with your footer. I said you have to move it out of the container. It being the footer. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070331 Share on other sites More sharing options...
zimmo Posted June 10, 2010 Author Share Posted June 10, 2010 Sorry I thought you was referring to what I had been told. How can I now position the footer then, if I take it out of the container, it is positioned at the foot of the viewable screen and when you scroll it stays there. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070339 Share on other sites More sharing options...
haku Posted June 10, 2010 Share Posted June 10, 2010 Then you must have different code than what you put in your first post - that code will not stick it to the bottom of the viewport, it will stick it to the bottom of the page. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070347 Share on other sites More sharing options...
zimmo Posted June 10, 2010 Author Share Posted June 10, 2010 Here is my code now: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Site</title> <link rel="stylesheet" type="text/css" href="../html/driving2.css" /> </head> <body> <div id="container"> <!-- Header Starts Here --> <div id="header"> <img src="../html/images/logo.gif" width="480" height="180" alt="Crafty Cakes" style="vertical-align:top"/> </div> <!-- Content Holder Starts Here --> <div id="content"> <div class="left"> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> <div class="right"> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> </div> </div> <!-- Footer Spacer Here --> <div id="spacer"> </div> <!-- Footer Starts Here --> <div id="footercontainer"> <div class="footer"> <ul> <li><a href="#">Link</a></li> </ul> <p><a href="#">Terms and Conditions</a></p> </div> </div> </body> </html> CSS /* CSS Style sheet */ html,body { margin:0; padding:0; height:100%; /* needed for container min-height */ font-family:arial,sans-serif; font-size:small; color:#666; } h1 { font:1.5em georgia,serif; margin:0.5em 0; } h2 { font:1.25em georgia,serif; margin:0 0 0.5em; } h1, h2, a { color:orange; } p { line-height:1.5; margin:0 0 1em; } div#container { position:relative; /* needed for footer positioning*/ margin:0 auto; /* center, not in IE5 */ width:100%; background-color: #000000; background-image: url(inc/mainbackground.gif); background-repeat: repeat-x; background-position: center top; height:auto !important; /* real browsers */ height:100%; /* IE6: treaded as min-height*/ min-height:100%; /* real browsers */ } div#header { position:relative; /* needed for footer positioning*/ width:1024px; height: 230px; margin:0 auto; /* center, not in IE5 */ } div#header p { font-style:italic; font-size:1.1em; margin:0; } div#content { position:relative; /* needed for footer positioning*/ width:1024px; margin:0 auto; /* center, not in IE5 */ padding:1em 1em 5em; /* bottom padding for footer */ height:100%; } div#content p { text-align:justify; padding:0 1em; } .left { position:relative; /* needed for footer positioning*/ width: 200px; float: left; } .right { position:relative; /* needed for footer positioning*/ width: 700px; float: right; } /* FOOTER */ div#footercontainer { position:absolute; width:100%; height: 100px; bottom:0; /* stick to bottom */ background-image: url(inc/footercontainer.gif); background-repeat: repeat-x; background-position: left top; } .footer { position:relative; /* needed for footer positioning*/ margin:0 auto; /* center, not in IE5 */ width:1024px; height: 100px; font: 12px Lucida Grande, Tahoma, sans-serif; color: #ffffff; background-image: url(inc/footer.gif); background-repeat: no-repeat; background-position: center top; } .footer ul { list-style: none; padding: 0; margin: 0; line-height: 40px; } .footer li { display: inline; margin: 0px; margin: 0; padding: 10px 10px 0px 10px; } .footer li a { text-decoration: none; color: #ffffff; } .footer li a:hover { color: #000000; } .footer p { padding: 0px 10px 0px 10px; } .footer p a { text-decoration: none; color: #ffffff; } .footer p a:hover { color: #000000; } /* END footer */ The footer with code above is showing viewport only. Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070366 Share on other sites More sharing options...
zimmo Posted June 10, 2010 Author Share Posted June 10, 2010 Please anyone... its driving me insane.... Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070416 Share on other sites More sharing options...
haku Posted June 10, 2010 Share Posted June 10, 2010 http://www.cssstickyfooter.com/ Quote Link to comment https://forums.phpfreaks.com/topic/204385-css-issue-with-footer/#findComment-1070417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.