473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to position a "footer" div? (Aligning with "bottom:0" aligns to the viewport and not to the containing element :-( )

Hi to All,

I am new to html authoring, so sorry if my terminology is not correct or
exact.

I would like to position a footer div to the bottom of the browser window.
As I research in the web shows this could be done a containing element with
"min-height: 100%;" and an absolute positioned element (div) inside, aligned
to bottom ("position: absolute; bottom:0px")

But here is the problem comes: Sometimes my page filled with more content
and vertical scrollbar shows up. In this case the bottom aligned footer not
aligned to the bottom of the containing div, but aligned to the bottom of
browser window (viewport?). This gives an erratic render because the footer
is in the middle of the content.

How can design the layout to statisfy this 2 requirement:

1) If the dynamic content of my page is less height than the browser window,
than the footer shows up at the bottom of the window
2) If the dynamic content of my page is more height than the browser window,
than the footer shows up at the bottom of the content, so we can scroll down
to see it?

thx for answer.
Feb 19 '07 #1
4 29344
On 2007-02-19, john <jo**@nospam.comwrote:
Hi to All,

I am new to html authoring, so sorry if my terminology is not correct or
exact.

I would like to position a footer div to the bottom of the browser window.
As I research in the web shows this could be done a containing element with
"min-height: 100%;" and an absolute positioned element (div) inside, aligned
to bottom ("position: absolute; bottom:0px")

But here is the problem comes: Sometimes my page filled with more content
and vertical scrollbar shows up. In this case the bottom aligned footer not
aligned to the bottom of the containing div, but aligned to the bottom of
browser window (viewport?). This gives an erratic render because the footer
is in the middle of the content.

How can design the layout to statisfy this 2 requirement:

1) If the dynamic content of my page is less height than the browser window,
than the footer shows up at the bottom of the window
2) If the dynamic content of my page is more height than the browser window,
than the footer shows up at the bottom of the content, so we can scroll down
to see it?
Using min-height:100% as you suggest should do exactly that, it may be
that it's just not working in the browser or browser-shaped-object
you're trying it in.

You do need the container (the one that's height:100%) to be positioned
as well, and if it's relatively positioned (as opposed to absolute or
fixed), you may need something like html, body { height: 100%; } to make
sure the percentages are all there and resolvable all the way up to the
viewport.

Even in a browser where this does work (Firefox), ISTR you get some
nasty effects when the user resizes the viewport, as if it were failing
to reflow completely with the new viewport size.
Feb 19 '07 #2
Mon, 19 Feb 2007 09:22:30 +0100 from john <jo**@nospam.com>:
I am new to html authoring, so sorry if my terminology is not correct or
exact.
What, you didn't like the answer you got the first time?
http://groups.google.com/group/comp....aa220a75c666b5
Please don't waste the group's time by posting the identical question
more than once. If you didn't understand something about the original
answers or need to discuss them further, follow up to the original
thread and don't start a new one.

And in particular, don't waste time by posting the identical copy to
the *wrong* group. There's a CSS group, where you asked your question
first. Posting it again to the HTML group is doubly wrong.

[followups to comp.infosystems.www.authoring.stylesheets]
--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 19 '07 #3

john skrev:
Hi to All,

I am new to html authoring, so sorry if my terminology is not correct or
exact.
That's okey, but the answer to your question hurts my feelings.
I would like to position a footer div to the bottom of the browser window.
As I research in the web shows this could be done a containing element with
"min-height: 100%;" and an absolute positioned element (div) inside, aligned
to bottom ("position: absolute; bottom:0px")
Let it flow, you don't need to use absolute positioned elements.
Absolute positioned elements "is removed from the normal flow entirely
(...)".

http://www.w3.org/TR/REC-CSS2/visure...te-positioning
But here is the problem comes: Sometimes my page filled with more content
and vertical scrollbar shows up. In this case the bottom aligned footer not
aligned to the bottom of the containing div, but aligned to the bottom of
browser window (viewport?). This gives an erratic render because the footer
is in the middle of the content.
Absolutely positioned boxses "(...) may or may not obscure the
contents of another box, depending on the stack levels of the
overlapping boxes."

http://www.w3.org/TR/REC-CSS2/visure...te-positioning
How can design the layout to statisfy this 2 requirement:

1) If the dynamic content of my page is less height than the browser window,
than the footer shows up at the bottom of the window
2) If the dynamic content of my page is more height than the browser window,
than the footer shows up at the bottom of the content, so we can scroll down
to see it?
With nested dividers and IE hacks:

<head>
<title>Dynamic Content without Irritating Enviroment</title>
<style>
html, body { margin: 0; padding: 0; height: 100% }
.main { position: relative; min-height: 100% }
.content { padding-bottom: 3em }
.footer { position: relative; margin-top: -3em; height: 3em }
</style>

<!--[if lt IE 7]>
<style type="text/css">
.main { height: 100% }
</style>
<![endif]-->
</head>

<body>
<div class="main">
<div class="content">Content</div>
</div>
<div class="footer">Footer</div>
</body>

Feb 20 '07 #4

john skrev:
Hi to All,

I am new to html authoring, so sorry if my terminology is not correct or
exact.

I would like to position a footer div to the bottom of the browser window.
As I research in the web shows this could be done a containing element with
"min-height: 100%;" and an absolute positioned element (div) inside, aligned
to bottom ("position: absolute; bottom:0px")
Let it flow, you don't need to use absolute positioned elements.
Absolute positioned elements "is removed from the normal flow entirely
(...)".

http://www.w3.org/TR/REC-CSS2/visure...te-positioning
But here is the problem comes: Sometimes my page filled with more content
and vertical scrollbar shows up. In this case the bottom aligned footer not
aligned to the bottom of the containing div, but aligned to the bottom of
browser window (viewport?). This gives an erratic render because the footer
is in the middle of the content.
Absolutely positioned boxses "(...) may or may not obscure the
contents of another box, depending on the stack levels of the
overlapping boxes."

http://www.w3.org/TR/REC-CSS2/visure...te-positioning
How can design the layout to statisfy this 2 requirement:

1) If the dynamic content of my page is less height than the browser window,
than the footer shows up at the bottom of the window
2) If the dynamic content of my page is more height than the browser window,
than the footer shows up at the bottom of the content, so we can scroll down
to see it?
<head>
<title>Dynamic Content without Irritating Enviroment</title>
<style>
html, body { margin: 0; padding: 0; height: 100% }
.main { position: relative; min-height: 100% }
.content { padding-bottom: 3em }
.footer { position: relative; margin-top: -3em; height: 3em }
</style>

<!--[if lt IE 7]>
<style type="text/css">
.main { height: 100% }
</style>
<![endif]-->
</head>

<body>
<div class="main">
<div class="content">Content</div>
</div>
<div class="footer">Footer</div>
</body>

Feb 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Harald Kirsch | last post by:
In the W3C document about CSS2, I read at http://www.w3.org/TR/REC-CSS2/visuren.html#choose-position the following: absolute The box's position (and possibly size) is specified with the...
2
by: Tristan Miller | last post by:
Greetings. I am trying to figure out how to use CSS to position an element in the bottom right of its containing element. I thought this would be accomplished using "position: relative; bottom:...
6
by: Gérard Talbot | last post by:
Hello fellow stylers, When trying this page http://www.gtalbot.org/BrowserBugsSection/PercentualRelativePositioning.html I get different rendered layouts with IE 6, IE 7 beta 2, Firefox...
26
by: Bill Norton | last post by:
If you wrap one division around another like this: <div id="wrapper"> <div id="child">...</div> </div> ....the wrapper division will be considered the containing block of the child division...
5
by: Robert | last post by:
Hi, I am currently trying to do some Javascript sizing and positioning using Javascript and encounter some for me unexpected behaviour in IE6, yet works fine in Firefox and Opera. I have a...
2
by: nonsensitor | last post by:
I'm just learning xhtml & css, primarily from westciv's online tutorials and css guide. I've run into a couple of problems with a page I'm developing that I can't figure out. The first problem is...
1
by: john | last post by:
Hi to All, I am new to html authoring, so sorry if my terminology is not correct or exact. I would like to position a footer div to the bottom of the browser window. As I research in the web...
2
by: soulmach | last post by:
Hello forum friends. I performed a search on this topic, but I couldn't find anything useful. I wasn't really sure what to search. First I'll state what I am trying to do. I recently agreed to...
5
Frinavale
by: Frinavale | last post by:
Hi! I'm attempting to display a <div> element on top of my page's content so that the user cannot interact with it while being prompted to answer a question. I have set this <div> to have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.