Jump to content

[SOLVED] Basline footer


rarebit

Recommended Posts

Hi,

I'm after a footer which when the content has less height than the overall page it sticks to the baseline, however if there is more than a page worth of content for it to be pushed down with it. This should hopefully demonstrate the issue:

<html>
<head>
<title>TEST</title>
<style type="text/css" media="all">
html {
margin: 0px;
padding: 0px;
}
body {
background: #ffffff;
color:#efefef;
font-family: arial,helvetica,geneva,sans-serif;
font-size: 14px;
margin: 0px;
padding: 0px;
}
#content_wrap {
width: 640px;
height: 100%;
background: #efefef;
margin: 0 auto;
}
#content_header {
width: 640px;
height: 50px;
background: #ff0000;
}
#content_main {
width: 400px;
background: #00ff00;
float: left;
}
#content_menu {
width: 240px;
background: #0000ff;
float: left;
}
#content_footer {
width: 640px;
height: 50px;
background: #ffff00;
clear: both;
position: absolute;
bottom: 0px;
}
</style>
</head>
<body>
<div id='content_wrap'>
<div id='content_header'>header</div>
<div id='content_main'>main<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	</div>
<div id='content_menu'>menu</div>
<div id='content_footer'>footer</div>
</div>
</body>
</html>

 

Cheers...

Link to comment
Share on other sites

Ah If i had a nickel for everytime someone does this.

You had position:absolute at the footer which mean if more content was added the footer would stick in place. You should not use so much position absolutes. I removed the position absolute from #content_footer and it worked exactly like you wanted it to.

 

Cheers

 

p.s. Add an xhtml transitional doctype. If you don't know it try googling it

Link to comment
Share on other sites

No!

If you remove the 'text' fill (i.e. no content) then the footer doesn't stick to the baseline. I'm not wanting to to use 'min-height' either. I've found an example earlier which works, but when I recreate it, it doesn't. I'll have another crack tomorrow and report back... It uses some hidden block content filler or something.

Link to comment
Share on other sites

Wait..you said you want if more content is added that the footer will stick underneath the content id's right? If you just use this code here then no matter what or how much content you have in there the footer will always be below the contents.

 

Sorry if this is not what you wanted but it sure sounds like it is.

 

<html>
<head>
<title>TEST</title>
<style type="text/css" media="all">
html {
   margin: 0px;
   padding: 0px;
}
body {
   background: #ffffff;
   color:#efefef;
   font-family: arial,helvetica,geneva,sans-serif;
   font-size: 14px;
   margin: 0px;
   padding: 0px;
}
#content_wrap {
   width: 640px;
   height: 100%;
   background: #efefef;
   margin: 0 auto;
}
#content_header {
   width: 640px;
   height: 50px;
   background: #ff0000;
}
#content_main {
   width: 400px;
   background: #00ff00;
   float: left;
}
#content_menu {
   width: 240px;
   background: #0000ff;
   float: left;
}
#content_footer {
   width: 640px;
   height: 50px;
   background: #ffff00;
   clear: both;
   bottom: 0px;
}
</style>
</head>
<body>
<div id='content_wrap'>
   <div id='content_header'>header</div>
   <div id='content_main'>main<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      text<br>text<br>text<br>text<br>text<br>text<br>text<br>
      </div>
   <div id='content_menu'>menu</div>
   <div id='content_footer'>footer</div>
</div>
</body>
</html>

Link to comment
Share on other sites

OK, earlier I used the source from the example, just now i've used the actual tutorial and wahey, here we go:

<html>
<head>
<title>TEST</title>
<style type="text/css" media="all">
html, body
{
margin: 0px;
padding: 0px;
height: 100%;
}
#nonFooter
{
position: relative;
min-height: 100%;
}
* html #nonFooter
{
height: 100%;
}
#content
{
padding-bottom: 110px;
}
#footer
{
background-color: #efefef;
position: relative;
margin-top: -100px;
height: 100px;
}
</style>
</head>
<body>
<div id="nonFooter">
<div id="content">
	content<br>
	<!--text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>
	text<br>text<br>text<br>text<br>text<br>text<br>text<br>-->
</div>
</div>
<div id="footer">Footer</div>
</body>
</html>

 

Cheers again Boltz

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.