April 15, 201115 yr I am re-doing my site, but having an issue with floats. I am going to be using the Sticky Footer 2010 style to have sticky footer on website. I have a central part of the website that the content goes. I have a side bar on the right, and I then want multiple divs that have content going down the left side. I have chosen to put them in a class as I plan on having multiple of them down that side. Of course the side bar doesn't stretch right to the bottom as it will just contain links generally. However, at the moment the side bar and everything is correct, but the two div classes are next to each other - I want them to be stacked below each other, and this pushes the sidebar down. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" l11/DTD/xhtml11.dtd"> <html xmlns="org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> - Home Page</title> <link href="/css/main.css" rel="stylesheet" type="text/css" /> <!--[if !IE 7]> <style type="text/css"> #wrap {display:table;height:100%} </style> <![endif]--> </head> <body> <div id="wrap"> <div id="header">Header</div> <div id="pri_nav">Pri Nav</div> <div id="sub_nav">Sub Nav</div> <div id="content_wrapper">Content <div id="content_central"> <div class="left_info"> <p>Left Info Upper</p> </div> <!-- End left_info class div --> <div class="left_info"> <p>Left Info lower</p> </div><!-- End left_info class div --> <div id="side_bar"> <p>Side bar</p> </div><!-- End of side-bar div --> <div class="clear"></div> </div><!-- end of content_central div --> </div><!-- End of content_wrapper div --> </div><!-- End of wrap div --> <div id="footer">Footer Here</div> </body> </html> @charset "utf-8"; /* CSS Document */ * {margin:0;padding:0;} html, body {height: 100%;} .clear {clear:both} #wrap {min-height: 100%; width: 100%; background-color: #f8f8f8;} #header{width: 100%; background-color: red; height: 500px;} #pri_nav{width: 100%; background-color: blue; height: 100px;} #sub_nav {width100%; background-color: green; height: 50px;} #content_wrapper {overflow:auto; padding-bottom: 150px;} /* must be same height as the footer */ #content_central {width: 900px; margin: 0 auto; background-color: yellow;} .left_info {width: 400px; float:left; height: 350px;} #side_bar {width: 250px; float:right; height: 500px;} #footer {position: relative; margin-top: -150px; /* negative value of footer height */height: 150px;clear:both;} /*Opera Fix*/ body:before {/* thanks to Maleika (Kohoutec)*/ content:""; height:100%; float:left; width:0; margin-top:-32767px;/* thank you Erik J - negate effect of float*/ }
April 15, 201115 yr Author Okay, I think I've fixed it. However, I need to separate the two class divs that are stacked without using 'margin-bottom: 15px' for example. Is this possible? It's advised, as far as I know, to not use margin top or bottom as that can cause problems with the css sticky footer. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Home Page</title> <link href="/css/main.css" rel="stylesheet" type="text/css" /> <!--[if !IE 7]> <style type="text/css"> #wrap {display:table;height:100%} </style> <![endif]--> </head> <body> <div id="wrap"> <div id="header">Header</div> <div id="pri_nav">Pri Nav</div> <div id="sub_nav">Sub Nav</div> <div id="content_wrapper">Content <div id="content_central"> <div id="left_side_bar"> <div class="left_info"> <p>Left Info Upper</p> </div> <!-- End left_info class div --> <div class="left_info"> <p>Left Info lower</p> </div><!-- End left_info class div --> </div><!-- End Left side bar --> <div id="right_side_bar"> <p>Side bar</p> </div><!-- End of side-bar div --> <div class="clear"></div> </div><!-- end of content_central div --> </div><!-- End of content_wrapper div --> </div><!-- End of wrap div --> <div id="footer">Footer Here</div> </body> </html> [code] @charset "utf-8"; /* CSS Document */ * {margin:0;padding:0;} html, body {height: 100%;} .clear {clear:both} #wrap {min-height: 100%; width: 100%; background-color: #f8f8f8;} #header{width: 100%; background-color: red; height: 500px;} #pri_nav{width: 100%; background-color: blue; height: 100px;} #sub_nav {width100%; background-color: green; height: 50px;} #content_wrapper {overflow:auto; padding-bottom: 150px;} /* must be same height as the footer */ #content_central {width: 900px; margin: 0 auto; background-color: yellow; padding: 15px;} #left_side_bar {width: 600px; float:left; padding: 15px;} .left_info { width: 570px; float:left; height: 350px; padding: 15px; } #right_side_bar { width: 210px; float:right; height: 300px; padding: 15px; } #footer {position: relative; margin-top: -150px; /* negative value of footer height */height: 150px;clear:both;} /*Opera Fix*/ body:before {/* thanks to Maleika (Kohoutec)*/ content:""; height:100%; float:left; width:0; margin-top:-32767px;/* thank you Erik J - negate effect of float*/ } [/code] Edited April 15, 201115 yr by jpw1984
Create an account or sign in to comment