Solved

Set up CSS so HTML is always 100% of browser view and footer is always on the bottom

Posted on 2011-03-13
8
429 Views
Last Modified: 2012-06-27
I want my site to display at 100% of the vertical space of the user's browser, with the footer always at the bottom of the page. This is especially important on pages that don't have a lot of content. I found a clever fix that has worked for me in the past here:

http://www.dave-woods.co.uk/index.php/css-fixed-footer/

Dave assigns the HTML height to 100% and places the footer at the bottom of that with some margin adjusting.

This works fine on this page:

http://justthedriver.com/employment/employment.htm

BUT doesn't work on this page:

http://justthedriver.com/contact/contact.htm

I'm guessing it has something to do with the Column L & Column R spacing on the Contact.htm page? Not sure though.

Please advise.

Thanks Experts!
0
Comment
Question by:TonyT7220
  • 4
  • 3
8 Comments
 
LVL 42

Accepted Solution

by:
David S. earned 250 total points
ID: 35125107
It works in neither page for me here.

One issue is that <body> needs its height set to 100% as well as <html>.

There are multiple ways to do it. Below is the approach I prefer. (The first rule should probably go in layout.css and the others in style3.css.)
html,
body {
	border: 0 none;
	margin: 0;
	padding: 0;
	height: 100%;
}

#container {
	background-color: #fff;
	width: 900px;
	margin: -40px auto 0;  
	/* negative top margin is to allow spacer for the footer */
	border: 1px solid #b7b7b7;
	border-top: 0 none;
	border-bottom: 0 none;
	min-height: 100%;
}
* html #container {height:100%} /* for IE6 */

#masthead {
	text-align: right;
	background-color: #369;
	width: 900px;
	padding-top: 40px; /* total height of the footer */
}

Open in new window

P.S. Why are style attributes used in those pages? It's best to keep all styles in external stylesheets (and  inside <style> elements as well, if necessary).
0
 

Author Comment

by:TonyT7220
ID: 35131417
Thanks for this..let me try it out ans let you know.
0
 

Author Comment

by:TonyT7220
ID: 35131550
Here is the page with your style specs:

http://justthedriver.com/employment/employment.htm

Not quite there.

Please advise.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 42

Expert Comment

by:David S.
ID: 35142005
It seems you didn't copy the "html," from the first rule. The selectors should be "html, body", not just "body"

Also you need to remove the inline styles from the "#container" element.
0
 

Author Comment

by:TonyT7220
ID: 35143466
Thanks Kravimir,

I corrected those errors on the following page:

http://JustTheDriver.com/employment/employment.htm

The one last thing the "container" div's background color of white is not going all the way down to the footer and a wedge of the grey background color shows thru. How do I correct this?

Thanks!
0
 

Author Closing Comment

by:TonyT7220
ID: 35143474
Tested this and it worked. Thanks Kravimir!
0
 
LVL 42

Expert Comment

by:David S.
ID: 35143560
You're welcome. I'm glad I could help.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Capture logon name 13 73
compact pure CSS Read More Toggle 4 69
Enforce Chrome to open certain links in IE 6 31
Box Locations 6 16
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question