Help - Search - Members - Calendar
Full Version: CSS Body Style/margin nightmare
ieXbeta Board > Tech > Developer Center
Phonics Monkey
Okay (Quickie background) Have large existing intranet website, that I need to add something to. The something I'm adding requires the XHTML 1.0 Doc Type ... or it shoots off the page. (ther in lying the problem...)

The existing site holds the page footer at the bottom of the page by setting body padding & margin to 0, and setting the main page table to height=100%. Which worked fine as even if the page had no content the footer still stayed (where the hell it belonged) "pinned" to the bottom of the page/browser window.

Now the instant I add the Doc Type XHTML 1.0 to the page, the "footer" suddenly decides it wants to spring up to the center of the page completely ignoring the height=100% part of the table description.

So...How the hell am I supposed to nail the footer to the bottom of the page where it belongs if this crazy assed Doc Type won't let me define the height of the main table?!?
DangerousDave86
I think I recognise this problem. Have you tried styling the html or body element to be 100% rather than the table?

Edit: You have to consider the height of the viewport, which is not necessarily the same size as the window - I think.
Phonics Monkey
QUOTE(DangerousDave86 @ Apr 24 2008, 12:48) *

I think I recognise this problem. Have you tried styling the html or body element to be 100% rather than the table?
If you mean in the Style/Body section of the css setting margin: 0px; padding: 0px; then yes is there another place I can put it?

QUOTE
Edit: You have to consider the height of the viewport, which is not necessarily the same size as the window - I think.
Viewable area is window - toolbars ...yes? The bottom of the table is being smashed into it's content, which is about half of the viewable area (on the main page).

I've thought about trying to lock the menu in a div layer to pin it in place, but (I'm not sure it'll work, and) I'd like to know what the "right" way of doing this is.

Thanks,
Phonics Monkey
DangerousDave86
Sorry, I mean, does adding
html, body { height: 100%; }
help at all?
What I thinks happening is that before the XHTML doctype. The HTML/Body elements default height was set to the height of the viewable HTML area (viewport) so that the 100% instruction made the table fill to the height of the window. Now, with XHTML the default HTML/Body height is not the height of the viewport, it is just the height of the content, making the 100% meaningless because the body is only as big as the content requires.

Sorry if I'm not explaining well.
Phonics Monkey
Hm... Kinda starting to sound like my answer is no. unsure.gif

I tossed in body height to no avail (still smooshed), here is a content stripped out copy of the code I'm playing with:
CODE
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
.style1 {
    border: 1px solid #000080;
}
</style>
</head>

<body style="margin: 0;height:100%">

<table style="width: 100%; height: 100%" cellspacing="3" class="style1">
    <tr>
        <td class="style1" style="width: 100%; height: 100%">&nbsp;</td>
    </tr>
</table>

</body>

</html>

Can you see anything I'm missing?
DangerousDave86
QUOTE(Phonics Monkey @ Apr 27 2008, 16:15) *

Hm... Kinda starting to sound like my answer is no. unsure.gif

Can you see anything I'm missing?


In my FireFox 2.0.0.14 this works fine:
QUOTE

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
.style1 {
border: 1px solid #000080;
}
html, body { height: 100%; }
</style>
</head>

<body style="margin: 0;">

<table style="width: 100%; height: 100%" cellspacing="3" class="style1">
<tr>
<td class="style1" style="width: 100%; height: 100%">&nbsp;</td>
</tr>
</table>

</body>

</html>

looks like you need to use both the HTML and Body tag.
However in my IE6 this stretches over 100% of the window - probably because of the broken box model and the border styling of the table.
I haven't got IE7 to check that.

Btw, here's an interesting read for XHTML (http://hixie.ch/advocacy/xhtml)
Not sure if your that into the whole web thing though.
Phonics Monkey
Nailed IT!!

IE7 did the same odd overlap, but that quirk I'm used to. Just pull the cell height=100% and it stops pushing the border out on the "window"

Thank You!
DangerousDave86
No problem wink2.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.