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
428 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Synchronizing CSS load 3 30
CSS change width browser switches to mobile view 2 55
Syntax Error 2 47
A simple Float not working. 5 7
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now