?
Solved

Attach footer div element to the bottom of page but keep it below content area

Posted on 2009-04-15
9
Medium Priority
?
699 Views
Last Modified: 2013-11-19
Hi there

Although this question has been asked a thousand times I just cant find a solution for the html/css layout i am working on.

I am working on css for a custom cms that I use, I need to keep the main sections (header, content, footer) html that it pumps out and use css to force the footer area to stay attached to the bottom of the page.

I have attached an html (remove .txt extension) file containing inline css and html file. The ideal result would mean:

1. The blue footer area streches to the bottom of the page.
2. The Purple inner footer is attached to the bottom of the blue footer area and therefore the bottom of the page
3.The purple inner footer will always sit below the red/green content area.

Any thoughts on this would be much appreciated as I just cant fix it.

Many thanks in advance

--s--
ee.html.txt
0
Comment
Question by:socross
[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
  • 5
  • 3
9 Comments
 
LVL 12

Expert Comment

by:Dimitris
ID: 24147978
here u r
the height of 87px of the footer should not be exited.
Changes made on the #footer class of the CSS

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Test</title>
		<style media="all" type="text/css">
/* Base Css */
:link, :visited {
	text-decoration:none;
}
ul, ol {
	list-style-image:none;
	list-style-position:outside;
	list-style-type:none;
}
h1, h2, h3, h4, h5, h6, pre, code {
	font-size:1em;
}
ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, body, html, p, blockquote, fieldset, input {
	margin:0;
	padding:0;
}
a img, :link img, :visited img {
	border:medium none;
}
.cl {
	clear:both;
	font-size:0.1px;
	line-height:0.1px;
}
a:active, a:focus {
	outline: 0;
}
/* Main Css */
html {
	background:#FFF;
}
body {
	font-family:"Lucinda Grande",Sans-serif;
	color:#FFF;
	font-size:12px;
}
#header {
	background:#000;
	height:136px;
	width:100%;
}
#header div.inner {
	background:#0F0;
	height:136px;
	margin:0 auto;
	position:relative;
	width:880px;
}
 
#content {
	background:#FF0000;
	float:left;
	width:100%;
}
 
#content #pattern {
	background:transparent none repeat scroll 0 0;
	float:left;
	width:100%;
}
 
#content div.inner {
	background: #030;
	margin:0 auto;
	height:auto !important;
	min-height:200px;
	width:880px;
}
 
#footer {
	background: #09F;
	clear:both;
	padding:0;
	position:absolute;
	left:0px;
	top:100%;
	margin-top:-87px;
	height:87px;
}
 
#footer div.inner {
	background: #F0F;
	height:auto !important;
	margin:0 auto;
	height:87px;
	width:912px;
}
</style>
	</head>
	<body>
		<div id="header">
			<div class="inner">Header Inner
			</div>
		</div>
		<div id="content">
			<div id="pattern">
				<div class="inner">Content Inner
				</div>
			</div>
		</div>
		<div id="footer">
			<div class="inner">Footer Inner
			</div>
		</div>
	</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:socross
ID: 24148150
Hi dankangr

Thanks for your solution, but it does not seem to work for me. I was aiming for the purple inner-footer div to still be centered and attached to the bottom of the page with the blue footer container still 100% width and filling the space at the bottom of the page.

Many thanks

--s--
0
 
LVL 11

Expert Comment

by:level9wizard
ID: 24148245
Not sure if this is what you're looking for but I had a similar question some time ago:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/CSS/Q_24078315.html

I hope this helps!
0
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!

 
LVL 1

Author Comment

by:socross
ID: 24148342
Thanks level9wizard

That was one of the tutorials i was using but I cant seem to apply it to this html/css layout.

It does exactly what i need but i cant my head round it!

Many thanks

--s--
0
 
LVL 12

Expert Comment

by:Dimitris
ID: 24150214
I think that this is what u want
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
                <title>Test</title>
                <style media="all" type="text/css">
/* Base Css */
:link, :visited {
        text-decoration:none;
}
ul, ol {
        list-style-image:none;
        list-style-position:outside;
        list-style-type:none;
}
h1, h2, h3, h4, h5, h6, pre, code {
        font-size:1em;
}
ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, body, html, p, blockquote, fieldset, input {
        margin:0;
        padding:0;
}
a img, :link img, :visited img {
        border:medium none;
}
.cl {
        clear:both;
        font-size:0.1px;
        line-height:0.1px;
}
a:active, a:focus {
        outline: 0;
}
/* Main Css */
html {
        background:#FFF;
}
body {
        font-family:"Lucinda Grande",Sans-serif;
        color:#FFF;
        font-size:12px;
}
#header {
        background:#000;
        height:136px;
        width:100%;
}
#header div.inner {
        background:#0F0;
        height:136px;
        margin:0 auto;
        position:relative;
        width:880px;
}
 
#content {
        background:#FF0000;
        float:left;
        width:100%;
}
 
#content #pattern {
        background:transparent none repeat scroll 0 0;
        float:left;
        width:100%;
}
 
#content div.inner {
        background: #030;
        margin:0 auto;
        height:auto !important;
        min-height:200px;
        width:880px;
}
 
#footer {
        background: #09F;
        clear:both;
        padding:0;
        position:absolute;
        left:0px;
        top:100%;
        margin-top:-87px;
        height:87px;
	width:100%;
}
 
#footer div.inner {
        background: #F0F;
        
        margin:0 auto;
        height:100%;
        width:912px;
}
</style>
        </head>
        <body>
                <div id="header">
                        <div class="inner">Header Inner
                        </div>
                </div>
                <div id="content">
                        <div id="pattern">
                                <div class="inner">Content Inner
                                </div>
                        </div>
                </div>
                <div id="footer">
                        <div class="inner">Footer Inner
                        </div>
                </div>
        </body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:socross
ID: 24150402
Thanks dankangr

Nearly there but not quite.

1. The blue footer section needs to expand to fill the space between the content div and bottom of the page.

2. The footer div needs to stay below the content div at all times.

Sorry to be such a pain.

Many thanks

--s--
0
 
LVL 12

Expert Comment

by:Dimitris
ID: 24152324
the problem that we can't set the footer div (blue) to get the remain of the page is due to the declaration of
<!DOCTYPE html PUBLICs "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/TR/xhtml1/
So whatI suggest is to add a background color of the body the blue and live the rest as is.
But if you don't have any color on the blue footer div then you will not have any problem because it will grow and shrink based on the contents of the footer div(pink).

I have tried an other way also to add a table with width and height 100% but the doctype declaration doesn't allow the object to grow in order to cover the entire page.

 
0
 
LVL 12

Expert Comment

by:Dimitris
ID: 24152381
also have a look here
even the the xhtml V 1.1 doesn't allow for a div to get the 100% of the body
http://www.w3.org/QA/2002/04/valid-dtd-list.html
0
 
LVL 12

Accepted Solution

by:
Dimitris earned 2000 total points
ID: 24152410
what seems to work is the
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

801 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