?
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
Medium Priority
?
435 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 1000 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

752 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