/    Sign up×
Community /Pin to ProfileBookmark

Footer won’t stay at bottom of page

My problem is the footer won’t stay at the bottom of the page.

I did try adding height:100% to the body of the css code, but no luck.

The page is at: [url]http://dustbear.awardspace.com/[/url]

If you have Firebug or something similar, you can view the css code.

I’d really appreciate any tips.

to post a comment
CSS

16 Comments(s)

Copy linkTweet thisAlerts:
@CentauriApr 28.2007 — Do you want the footer to just stay under any content of the page (and not hide behind the menu), or position at the bottom of the window ?

The footer does not position below the menu at the moment due to the menu being absolutely positioned - floating the menu left instead allows the footer clear to clear the float : [CODE]#sidecontainer {
[COLOR="Red"]float:left[/COLOR];
margin: 0px;
[COLOR="Red"]width: 210px[/COLOR];
height: auto;
padding: 1em 0;
font: 12px Verdana, sans-serif;
text-align: center;
}[/CODE]
Note I also changed the width spec - the % width causes the menu to be too narrow for text on smaller screens.

If you want the footer to be positioned at the bottom of the screen unless the content is longer, then this can be done but is involved and requires a number of changes to your code, both html and css.

Cheers

Graeme
Copy linkTweet thisAlerts:
@WebJoelApr 28.2007 — My problem is the footer won't stay at the bottom of the page.

I did try adding height:100% to the body of the css code, but no luck.

The page is at: http://dustbear.awardspace.com/

If you have Firebug or something similar, you can view the css code.

I'd really appreciate any tips.[/QUOTE]


"height:100%" on an element won't work unless in your CSS you apply it to

[B]body, html[/B]{height:100%}

This seems familiar... -didn't I post a template with a working example how~to? ?
Copy linkTweet thisAlerts:
@dustbearauthorMay 02.2007 — Graeme, this worked great, although I'd rather have the footer positioned at the bottom of the window. I'd want to learn how to make the changes to the html and css, but I don't know where to go. It can get confusing. :eek:

WebJoel, I did try the body, html{height:100%}[/QUOTE] first, but the footer didn't move down.?

Thanks again, this is a wonderful forum (my first ever!).
Copy linkTweet thisAlerts:
@CentauriMay 02.2007 — To get the footer at the bottom of the page, it must be referenced to something that takes up the full height. If the entire site is wrapped in a wrapper div that has its minimum height set to 100%, then the footer can reference the bottom of this. To get a wrapper div 100% height, its parent (the body) needs to be set to 100% height, and likewise for its parent (the html). Hence the "html, body {height: 100%;}" WebJoel mentioned. Of course, IE6 doesn't know about min-height, so it is fed height via a "* html" css entry.

Placing the footer after the wrapper div obviously will place it [B]below[/B] the bottom of the screen. If the footer is given a height, then it can also be given a negative top margin equal to the height, which will "pull" it back up over the bottom of the wrapper. To avoid the footer covering any content, a bottom padding equal to or greater than footer height can be applied to the content div.

I also noticed there were quite a few discrepencies in spacings and text size between browsers elsewhere on the page, so while I was playing around with the footer, I reorganised the rest of the page as well. I also got rid of a number of wrapping divs - in most cases the elements can be styled directly without putting them in a div (eg navigation <ul>s). Some work around the horizontal navigation has it displaying as I would think you intend it. I also set up the top logo as a semantically meaningful heading text syled as the graphic.

Try this html [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css" media="screen, print, handheld">
<title>Car Stuff Just For Girls</title>
<meta name="Description" content="How to maintain your car or truck for as long as you own it. For girls of
all ages; girls who drive a car or truck. It is not how to change the oil, it's knowing when to change it
that's important. A useful place to find out more about your car. Definitions, parts, schedules and the
owner's manual. To provide information about the vehicle you own, so you can make an informed decision about
maintaining it. This website is for girls who drive a car and want it to last longer and run efficiently.">
</head>

<body>
<div id="wrapper">
<h1>Car Stuff Just For Girls</h1>
<ul id="navcontainer">
<li><a href="index.html" class="current">Home</a></li>
<li><a href="sitemap.html">Sitemap</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="links.html">Links</a></li>
<li><a href="guestbook.html">Guestbook</a></li>
<li><a href="abtus.html">About Us</a></li>
</ul>
<ul id="navlist">
<li id="active"><a href="maintmain.html" id="current" title="schedules,checklist,owner's manual">Maintenance</a></li>
<li><a href="glossarymain.html" title="abbreviations,definitions,labels">Glossary</a></li>
<li><a href="partinfomain.html" title="how to change a car tire,wiper blades...">Part Information</a></li>
<li><a href="engmain.html" title="fluids,filters,hoses">The Engine</a></li>
<li><a href="shop/shopmain.html" title="repairs,work orders,second opinions">Shops</a></li>
<li><a href="safemain.html" title="car checklist what to carry">Safety</a></li>
<li><a href="diduknowmain.html" title="statistics,how your car is put together">Did you know</a></li>
<li><a href="moremain.html" title="recalls,used car purchase checklist">More...</a></li>
</ul>
<div id="content">

<h2>Objective of this Web site:</h2>

<ul>
<li>To show you what your car needs to be maintained properly</li>
<li>To plan a maintenance schedule</li>
<li>To understand the information provided with each car and truck</li>
<li>Checking of fluid levels</li>
</ul>
</div>
</div>
<div id="footer">

Copyright &copy; Carstuffjustforgirls2004

</div>




</body>
</html>[/CODE]

and this css [CODE]/* body styles */
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
body
{
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
background-color: #fff;
color: #000088;
}
#wrapper {
min-height: 100%;
}
* html #wrapper {
height: 100%;
}

/*header styles */
h1 {
display: block;
height: 113px;
font-size: 1px;
text-indent: -1000px;
background-image: url(logo.jpg);
background-repeat: no-repeat;
background-position: 6px 10px;
}

/* content styles */
#content
{
position:relative;
background: #fff;
color: #000088;
margin-left: 235px;
margin-right: 20px;
padding: 15px 15px 30px 5px;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 15px;
text-align:justify;
}
#content h2 {
font-size: 30px;
margin: 1ex 0;
}
#content ul {
text-indent: 20px;
list-style-position: inside;
}



a img{border:none;}

.left
{
float: left;
clear: both;
}




/* partglossary content styles*/








/* sidecontainer styles */
#sidecontainer
{
float:left;
margin: 0px;
width: 210px;
height: auto;
padding: 1em 0;
font: 12px Verdana, sans-serif;
text-align: center;
}



#navlist
{
text-align: left;
list-style: none;
margin: 15px 0 0 30px;
float: left;
display: inline;
}

#navlist li
{
display: inline;
}

#navlist a
{
display: block;
padding: 0.5em 0 0.5em 2em;
border-width: 1px;
border-color: #ffe #aaab9c #ccc #fff;
border-style: solid;
color: #448;
text-decoration: none;
background: #dde;
width: 10em;
font: 12px Verdana, sans-serif;
}

#navlist #active a
{
color: #448;
}

#navlist a:hover, #navlist #active a:hover
{
color: #448;
background: transparent;
border-color: #aaab9c #fff #fff #ccc;
}



/* tabbed styles */
#navcontainer {
border-bottom: 1px solid #778;
font: bold 12px Verdana, sans-serif;
padding-left: 200px;
height: 21px;
overflow: visible;
}
#navcontainer li {
list-style: none;
display: inline;
}
#navcontainer a {
padding: 0 0.5em;
margin-left: 3px;
border: 1px solid #778;
background: #DDE;
text-decoration: none;
display: block;
height: 20px;
line-height: 20px;
float: left;
}
* html #navcontainer a {
border-bottom: 0;
}
#navcontainer a:link {color: #448;}
#navcontainer a:visited {color: #667;}
#navcontainer a:hover {color: #000; background: #AAE; border-color: #227;}
#navcontainer .current, #navcontainer .current:hover {
border-bottom-color: #DDE;
background-color: #DDE;
}



/* footer styles */
#footer
{
clear: both;
width: 95%;
text-align: left;
padding: 5px 0 0 5px;
border-top: 1px dashed #778;
color: #000088;
background: #fff;
font-size: 8px;
height: 20px;
margin: -26px auto 0;
}
[/CODE]


Cheers

Graeme
Copy linkTweet thisAlerts:
@dustbearauthorSep 18.2007 — Hi Graeme:

I want to thank you for all your help. Been long summer, death of a close relative and death of 2 jobs, and I'm back in the saddle again (if that's possible). Long summer, anywho...


Referring to the logo. It was mostly a placeholder for a future logo design change. I've thrown together another jpg, but I want to link it to the homepage. I wanted to originally make it an independent logo that you can click on to get to the homepage. I just can't figure out this simple task!

Also, I want to put a background picture (like a watermark, I think) on different pages. If I add it to the body, the content div hides it. What can I do? Remove the content div??

check it out at: http://dustbear.awardspace.com/
Copy linkTweet thisAlerts:
@CentauriSep 19.2007 — As the <h1>, being a block element, stretches the entire width of the wrapper, it can contain any header graphic you like, including one that goes full width. A link can be applied as a transparent "hot spot" and can be positioned anywhere on the graphic you want the link - you don't necessarily need a separate graphic for the link (similar to an image map, but accessible).

I noticed in your <h1> css that you have [COLOR="Blue"]background-position: 10px 5px 5px 10px;[/COLOR] - the background position property should only have two values, the first being the horizontal position and the second being the vertical position. If the css is changed to [COLOR="Blue"]background-position: 10px 5px;[/COLOR] then the background image will be 10px from the left edge and 5px from the top. As a background will be clipped to the size of the container, allowance for the background position needs to be made in the height of the container - adding an extra 10px to the height will give you 5px gap top and bottom of the background graphic.

A logo link can be applied like :[CODE]<h1>Car Stuff Just For Girls - Home Page</h1>
<a href="index.html" title="back to the Site Home Page" id="homelink">Home page link</a>[/CODE]
I changed the <h1> text to label the actual page better - this can be different for each page and have no effect on the graphic displayed in its place. The link has actual text for the benefit of non-visual browsers, and a title lets the user know what the link is when they mouse over the logo.

The css for this section is:[CODE]h1 {
display: block;
height: 123px;
font-size: 1px;
text-indent: -1000px;
background-image: url(logo.jpg);
background-repeat: no-repeat;
background-position: 10px 5px;
}
#homelink {
position: absolute;
top: 5px;
left: 10px;
width: 161px;
height: 113px;
font-size: 1px;
color: #03076B;
}[/CODE]
Here the link is absolutely positioned over top of the logo graphic - the location being set by the top and left co-ordinates, and the width and height matches the logo graphic (or part section of the graphic if desired). The text treatment shows another method of hiding the link text - reducing it to 1px high and then colouring it to match the background colour. Negative text indent can be used to hide it if you prefer - your choice. This then puts a transparent link "box" over top of the h1 graphic, and can be positioned and sized to only link a smaller area of the graphic if you like.

The background problem can be solved easily by removing the line [COLOR="Blue"]background: #fff;[/COLOR] from the #content div css, thereby making it transparent to allow the body background image to show through.
Copy linkTweet thisAlerts:
@dustbearauthorSep 19.2007 — If you check out http://dustbear.awardspace.com/ you'll see that I got the background part right away. I'd like to move the background images further right.

In the h1 css I changed the background position to bottom left and I like the result.

I think what I need is a hot spot. I'm not sure. I want this on all my pages; to click to the home page.
Copy linkTweet thisAlerts:
@CentauriSep 19.2007 — Looks good.

To get your homepage link hotspot in the right position, use the html I posted last, and change the css so that it is positioned in the top left corner :
[CODE]#homelink {
position: absolute;
top: 0;
left: 0;
width: 161px;
height: 113px;
font-size: 1px;
color: #03076B;
}[/CODE]


I noticed the page brings up both horizontal and vertical scrollbars, and this is due to the set width of #footer being 100% and the left padding is [B]added[/B], making it too wide. As a div normally expands to fill the container, the width is not required. Also, to allow the body background to show through the footer on small screens, you can also get rid of the footer background :
[CODE]#footer
{
clear: both;
text-align: left;
padding: 5px 0 0 5px;
border-top: 1px dashed #778;
color: #000088;
font-size: 8px;
height: 20px;
margin: -26px auto 0;
}[/CODE]
Copy linkTweet thisAlerts:
@dustbearauthorSep 20.2007 — Regarding the footer, I didn't notice any horizontal and vertical scrollbars. What browswer are you using? I tried reducing the browser window, but still didn't get any scrollbars. I did happen to change the width of the footer from 95% to 100%. The border didn't reach both sides of the screen (picky) and so I changed it to 100. Thanks for the "background colour" tip. It's coming together. ................ .the homelink is perfect! To clarify how this works; the h1 element is a box that covers up the text "Home page link" because the text is 1px and sits in the top left corner, or because the text is under the h1 element? How does this sit within the DOM? :eek:
Copy linkTweet thisAlerts:
@dustbearauthorSep 20.2007 — in reference to the "homelink", too bad I have to change all my pages manually, or is there an easier way?
Copy linkTweet thisAlerts:
@CentauriSep 21.2007 — The <h1> element is actually a box that extends all the way across the screen, and displays your logo as the background whilst shifting the actual text off the left of the screen. The #homelink <a> element is essentially a clear box the same size as the logo, positioned right over top of it - the link text is very small at the top left corner of this box, and the colour clamouflages it against the logo colour - if you look VERY closely, you may be able to see it depending on how well the colour match is.

When the footer div had the padding [B]and[/B] the 100% width on it, it brought up the horizontal scrollbar in FF 1.5. Without the padding, the 100% width would be ok, but is generally not needed as a div will expand to 100% of available width anyway.

Things like the homelink and navigation can be put into an exterrnal file and included on each page using SSI or PHP, and this has the advantage of only one file needing to be modified if extra stuff needs to be added/changed in this area. However, to implement that, you would still have to manually edit each existing page anyway.
Copy linkTweet thisAlerts:
@dustbearauthorSep 22.2007 — In reference to the homelink, I had no idea that the text was actually on top of the graphic. I thought it sat underneath. If I change the graphic, then I may have to change the colour of the font to make it camoflauge. Too bad I can't make the text transparent.

As for the footer, I am using FF 2.x so I didn't see it. Should I download a bunch of browsers, or is there a site to test various versions of browsers out there?

If I understand you correctly, the homelink link, and navigation I'm using (navcontainer & navlist) can be updated with PHP or SSI? I've already changed each file several times, but would prefer not to. I know what the acronyms mean (PHP and SSI), but can you direct me where to get help on learning this?

I've still got some basic stuff to fix before changing all that, like font size in the content area, list items that don't indent, and a couple of pages that won't validate. I'm not sure but I think I should start a new post for these.

Thanks again for all your help! ?
Copy linkTweet thisAlerts:
@CentauriSep 22.2007 — The camouflage method was used to illustrate another method of hiding the text - instead of colouring the text, you could use the negative text indent method as used on the <h1> if you like.

The footer should have caused scrollbars in FF2 as well when both the padding and 100% width were present - you may not have noticed it before removing the padding.

All of the html defining the header and both menus [CODE] <h1>Car Stuff Just For Girls</h1>

<a href="index.html" title="back to the Site Home Page" id="homelink">Home page link</a>
<ul id="navcontainer">

<li><a href="index.html" class="current">Home</a></li>
<li><a href="sitemap.html">Sitemap</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="links.html">Links</a></li>

<li><a href="guestbook.html">Guestbook</a></li>
<li><a href="abtus.html">About Us</a></li>

</ul>
<ul id="navlist">
<li id="active"><a href="maintmain.html" id="current" title="schedules,checklist,owner's manual">Maintenance</a></li>
<li><a href="glossarymain.html" title="abbreviations,definitions,labels">Glossary</a></li>

<li><a href="partinfomain.html" title="how to change a car tire,wiper blades...">Part Information</a></li>
<li><a href="engmain.html" title="fluids,filters,hoses">The Engine</a></li>
<li><a href="shop/shopmain.html" title="repairs,work orders,second opinions">Shops</a></li>

<li><a href="safemain.html" title="car checklist what to carry">Safety</a></li>
<li><a href="diduknowmain.html" title="statistics,how your car is put together">Did you know</a></li>
<li><a href="moremain.html" title="recalls,used car purchase checklist">More...</a></li>

</ul>[/CODE]
can be clipped out of the main file and put into a separate file named, say, "menus.html", and this file included in each page. This separate file should include [B]ONLY[/B] the clipped code, no doctype, no html, head or body tags, [B]just[/B] the code. If your server supports php, then the external file can be included by using [CODE]<?php include('menus.html'); ?>[/CODE] in the pages at the location the code was cut from. The pages will then have to be renamed with .php file extensions instead of .html (and the links in the menu itself will have to be updated to use .php file extensions). For local testing you have have to install a web server locally on your computer (I use xampp) SSI works in a similar way, although the syntax is slightly different and the pages need a .shtml file extension. More info about php can be seen here.

The list indenting problem would be due to the fist css rule zeroing default margins and padding - using a left margin on the <li>s will provide the multi-level indenting, and doing it this way is advantageous as different browsers defaults treat the indent in different ways.
Copy linkTweet thisAlerts:
@dustbearauthorSep 25.2007 — I just installed xampp, but I'm still figuring it out.

Seems I just put my web content in "xampphtdocs", then open up the file in a browser through Apache.
Copy linkTweet thisAlerts:
@CentauriSep 25.2007 — Yes, htdocs is the "www" folder you would put the site into on an internet server. You can access it through the browser at the address [CODE]http://localhost/foldername/pagename[/CODE]
Copy linkTweet thisAlerts:
@dustbearauthorOct 02.2007 — Having a problem with xampp, so I aborted the php thing for the moment.

I got so far and plan to pursue it shortly. :o

For now, I guess it worked on my paid server or I wouldn't have seen it.
×

Success!

Help @dustbear spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...