Forum Moderators: not2easy
I am working on <> and am having trouble with the bottom footer div. I think it would look better with it just sitting under the main content div and not extending under the menu. Everytime I tinker with the CSS I get it to move over but it doesn't take on the same width as the main div, just creates a horizontal scroll.
Please, can anyone help?
Ellie
[edited by: SuzyUK at 2:59 am (utc) on May 26, 2008]
[edit reason] Please No URI's, see guidelines at top of forum [/edit]
/* CSS Document */
html,body{
margin:0;
padding:0;
background-color: #DDE1E0; }
body{
font-size: 0.8em;
margin-left: 5%; margin-right: 5%; margin-top: 1%; }
h1,h2,h3 {
font-family: "Arial Rounded MT Bold", "Eras Bold ITC", Arial, sans-serif;
color: #003333;
margin: 10px 10px 10px;
line-height: 120%;}
p{
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #003333;
margin: 10px 10px 10px;
line-height: 120%;}
.highlight {
color: 000033;
background-color: #FFCC00; }
a{
display: compact;
color: #981793; }
ul li {
color: #003333;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 1em;
list-style-type: disc;
line-height: inherit;
text-align: left;
padding-right: 3px; }
div#header h1{
margin: 10px 0;
padding-left: 10px;
color: #295245;
height: 85px;}
div#content h1
{line-height: 1;}
div#header {
background-color: #669999;
background-image:url(.././images/dataturq.jpg);
background-position:top right;
background-repeat:no-repeat; }
div#footer
{background-color: #669999; color: #FFF;
background-image:url(.././images/datafootturq.jpg);
background-position:bottom right;
background-repeat:no-repeat;
width: 80%;
float: right;}
div#footer p
{margin:0; padding-left: 10px; padding-right: 10px; padding-top: 10px; height: 48px;}
div#wrapper{
width: 100%; }
div#content{
width: 75%;
background-color: #9CCFC0;
margin-top: 5px;
margin-bottom: 5px;
padding-right: 40px;
background-image:url(.././images/sidestripindex.jpg);
background-position:top right;
background-repeat: repeat-y;
float: right;}
div#navigation{
float: left;
width: 18%; }
div#extra{
float: left;
clear: left;
width: 18%;
margin-top: 5px;
margin-bottom: 5px;
background-color: #9CCFC0;}
ul.postnav,ul.postnav li{margin:3px 0;padding:0;list-style-type:none}
ul.postnav li{float:left;width: 100%;font-size:1.2em;margin-right: 5px}
ul.postnav a{display:block;width:100%;padding:5px 0;font: bold 100% Verdana,Arial,sans-serif;
background: #48B7B7;color: #295245;
text-decoration:none;text-align:center}
ul.postnav a:hover{background: #66ffff;color:#295245}
ul.postnavlil,ul.postnavlil li{margin:5px 0;padding:0;list-style-type:none}
ul.postnavlil li{float:left;width: 100%;font-size:1em;margin-right: 5px}
ul.postnavlil a{display:block;width: 100%;padding:5px 0;font: bold 100% Verdana,Arial,sans-serif;
background: #59E1E1;color: #295245;
text-decoration:none;text-align:center}
ul.postnavlil a:hover{background: #66ffff;color:#295245}
The html code is:
<div id="wrapper">
<div id="header"><h1>Title <br /> more title </h1></div>
<div id="content">
<h2>Title</h2>
<p>favourite foo text</p>
</div>
<div id="navigation">
<ul class="postnav"><li id="home"><a href="#">Home</a></li></ul>
<ul class="postnavlil"><li id="story"><a href="#" title="#">The Story</a></li></ul>
</div>
<div id="extra">
<p><strong>Extra Div</strong></p>
<p>You are in the homepage... foo foo </p>
</div>
<div id="footer"><p>© 2008<br />footer text</p></div>
</div>
[edited by: SuzyUK at 2:11 pm (utc) on May 30, 2008]
[edit reason] shortened HTML [/edit]
Anyway, here's some code I use for one of my sites, modified slightly.
#container {
position: relative;
display: block;
background: #FFFFFF; /* background color of the middle */
border-left: 200px solid #55834D; /* background of left */
overflow: visible;
padding: 0px;
margin: 0px;
}
#navigation {
float: left;
position: relative;
width: 200px;
margin-left: -200px;
display: inline;
}
#contents {
padding: 0px;
margin: 0px;
}
#foot {
display: block;
height: 55px;
padding: 0px;
margin: 0px;
}
.footpad {
padding: 10px 20px 0px 20px;
float: left;
}
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<!-- *******For internet explorer to see properly******* -->
<!--[if IE]>
<style type="text/css">
#container {display:inline-block;}
#left {width:197px;}
</style>
<![endif]-->
</head>
<body>
<div id="container">
<div id="navigation">
Navigation/left side contents here
</div>
<div id="contents">
Main section contents here
</div>
</div> <!-- Close container div -->
<div id="foot">
<div class="footpad"> <!-- to space text correctly -->
Footer contents
</div>
</div>
</body>
The only problem I have with this is that the footer is decided by where all of the contents and left-side navigation ends. So if you have very little content and a short navigation menu, then the footer will be halfway up the page; where-ever that section is over.
However, that could probably be solved by simply adding in some extra spacing at the end of the contents area, or under the navigation menu, so that it's always there.
your footer is "creeping over" becasue it's wider than the content div, your content div = 75% + 40px right padding so you should make the footer div the same in order to make it match (80% is not necessarily the same as 75%+40px)
the floats dropping will happen when the window isn't wide enough to have the content of both sides, side by side you can make an allowance for that by putting a min-width on the container say around 800px.. IE and below don't support min-width but there are workarounds out there. If you require one ~ try search for IE Min-Width hack
[edited by: SuzyUK at 2:18 pm (utc) on May 30, 2008]
div#wrapper{
width: 99%;
min-width: 700px;
width:expression(document.body.clientWidth < 765? "700px" : (document.body.clientWidth > 1300? "1280px": "99%" ) ); }
div#content{
width: 75%;
background-color: #9CCFC0;
margin-top: 5px;
margin-bottom: 5px;
padding-right: 40px;
background-image:url(.././images/sidestripindex.jpg);
background-position:top right;
background-repeat: repeat-y;
float: right;}
div#navigation{
float: left;
width: 19%; }
div#extra{
float: left;
clear: left;
width: 19%;
margin-top: 5px;
margin-bottom: 5px;
background-color: #9CCFC0;}
Hacks: for IE6: please don't. Use conditional comments instead (and move things like that expression in it).
The drop down: I'd bet it's the broken box model causing it. Try narrowing the width of the floated elements.
it's something to do with the list items in the left sidebar
adding clear:left; to the nav ul's fixed it for me..
div#navigation{
float: left;
clear: left;
width: 19%;
}
also I don't see that you need those right margins on your li elements they could be doing something too.. the min width you have only allows a margin of error of 1px (gap between the columns) so those 5 are too much, if you want a bigger gap you will likely need to change the width of one of your columns down by and percent or 2
e.g. @ 700px width
wrapper = 700 x 99% = 693px
left = 693 x 19% = 132px
right = (693 x 75%)+40px = 560px
both columns = 692px in a 693px wrapper = 1px gap
-Suzy
Thanks again. So appreciative.
Ellie