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
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

733 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