Forum Moderators: not2easy

Message Too Old, No Replies

layout issue IE vs Firefox

hopefully a quick fix! :)

         

thenewbigmack

3:57 am on Dec 18, 2009 (gmt 0)

10+ Year Member



Hey guys.. This is my first post and let me say, I am by no means an expert at HTML and CSS. I want to make a site for me and a friend, which a specific background image. When you click the link, you'll see the image and it should stretch to the resolution of your screen. One problem, on firefox, the text is on top of the image just like i want. But on IE, the text is placed below the image all together...? Thanks in advanced guys. And yes i know... I'm sure there are many errors =/

[edited by: tedster at 4:55 am (utc) on Dec. 18, 2009]
[edit reason] no personal urls, please [/edit]

thenewbigmack

7:05 am on Dec 18, 2009 (gmt 0)

10+ Year Member



sorry guess i can't post links... didn't know that. here is the coding I am using...

<style type="text/css">
html {height:100%;}
body {height:100%; margin:0; padding:0;}
#bg {position:fixed; top:0; left:0; width:100%; height:100%;}
#content {position:relative; z-index:1;}
</style>
<!--[if IE 6]>
<style type="text/css">
html {overflow-y:hidden;}
body {overflow-y:auto;}
#bg {position:absolute; z-index:-1;}
#content {position:static;}
</style>
<![endif]-->
</head>

<body>
<div id="bg"><img src="http://example.com/mtbaker1.jpg" width="100%" height="100%" alt=""></div>
<div id="content"><p>

CONTENT

</p></div>
</body>
</html>

I was just reading something about a doctype... will that effect this coding? I have actually never heard of that before, which is probably a bad thing. Thanks guys!

[edited by: SuzyUK at 12:05 pm (utc) on Dec. 18, 2009]

SuzyUK

12:03 pm on Dec 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi thenewbigmack, and Welcome to WebmasterWorld!

I guess you're reading the intro posts now, as you're mentioning Doctypes ;) Yes we don't do personal links or site reviews here - instead we aim to try and help via teaching rather a quick fix for any particular situation, as you read more read the charter linked to at top of forum too, you'll get a better feel for the place.

The code sample you've now posted is great

A Doctype is important as it will help your future CSS support, and enable you effectively deal with IE a little easier, it's a bit much to explain it all to you but try this thread [webmasterworld.com] for more information.

However to get you started with I suggest using:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

just put that before the opening <html> tag this puts IE6/7 in their most "standard" mode, which means they act more they are supposed to ;)

now as to your code, I'm not sure you're going about in the best way, if that image is a background image then you can put it as a background property on the body element.

However if you're actually trying to stretch/shrink that image to fit the screen (which it looks like you are using 100% width and height) then I would advise testing it in many different resolutions just so you're sure lou like the distortion that will possibly appear.. then yes if you still want to go ahead The Doctype should most certainly help in this case, as I can see the problem you are describing when IE is in 'quirks rendering' mode - which it will be if you've either No Doctype or a malformed one.

try that one I gave you and see if the problem goes away, if it causes you more display issues with other content it could be that you now have some workarounds in place that will not be necessary

hth
and Welcome again!