HTML Help Forum HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

Browser issues, IE8 misplaces body content
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum -> General HTML
View previous topic :: View next topic  
Author Message
tyguy87



Joined: 13 Nov 2009
Posts: 4

Posted: Fri Nov 13, 2009 1:34 pm     Browser issues, IE8 misplaces body content  

My code works perfectly in Firefox and Chrome but it's messed up in Internet Explorer. In IE8, it drops the content down below the background image. Also, it seems like the background image doesn't stretch the way I want it too.

Here is the code:

--------------------------------------

<style type="text/css">
html, body {height:100%; margin:0; padding:0;}
#page-background {position:fixed; top:0; left:0; width:100%; height:100%;}
div#container
{
width: 800px;
position: relative;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align: left;
}
body
{
text-align: center;
margin: 0;
}
</style>
<!--[if IE 6]>
<style type="text/css">
html {overflow-y:hidden;}
body {overflow-y:auto;}
#page-background {position:absolute; z-index:-1;}
#container {position:static;padding:10px;}
</style>
<![endif]-->
</head>
<body>
<div id="page-background"><img src="images/bg3.png" width="100%" height="100%"></div>
<div id="container">


-----------------------------------------

I would appreciate your help. Thanks!
sticks464



Joined: 31 Dec 2006
Posts: 2627

Posted: Fri Nov 13, 2009 3:35 pm      

In order to work properly the background image must be set in the body css. IE really has a hard time with 100% height.

This will center and set background in all browsers.
Make sure to use a valid doctype.
Code: <style type="text/css">
* {
margin:0;
padding:0;
}

body {
background:url(img src="images/bg3.png") no-repeat top left fixed;
text-align: center;
}

div#container {
width: 800px;
position: relative;
margin: 0 auto;
text-align: left;
}
</style>


</head>
<body>

<div id="container">
tyguy87



Joined: 13 Nov 2009
Posts: 4

Posted: Sat Nov 14, 2009 1:00 am      

Hey sticks, thanks for replying and helping me out.

I used your suggested code and everything's all centered properly now, but the image isn't being loaded at all in any of the browsers anymore. I haven't moved it or anything, but I don't know how to tell it where to find the background image.

Do you know how I could correct that?

Thanks again.
sticks464



Joined: 31 Dec 2006
Posts: 2627

Posted: Sat Nov 14, 2009 4:41 am      

Correct my bad by editing this line
Code: background:url(img src="images/bg3.png") no-repeat top left fixed; to
Code: background:url(images/bg3.png) no-repeat top left fixed;
tyguy87



Joined: 13 Nov 2009
Posts: 4

Posted: Sat Nov 14, 2009 9:52 am      

Thanks again, sticks. With your code, the background image displays but it doesn't stretch out, which I need it to. I tinkered with it a little and came up with this:

Code: <style type="text/css">
*{
margin:0;
padding:0;
}
body {
background:url(images/bg3.png); width: 100%; height: 100%; position: static;
text-align: center;
}
div#container {
width: 800px;
position: relative;
margin: 0 auto;
text-align: left;
}
</style>
</head>
<body>
<div id="container">

But it's still not quite right. Both Firefox and IE8 do everything right except for stretching out the height of the background image. Instead, it repeats the image below itself.

Here's the website: www.greenimprovementsllc.com/home.html
sticks464



Joined: 31 Dec 2006
Posts: 2627

Posted: Sat Nov 14, 2009 10:22 am      

You can't stretch a background image with css. It will display as actual size.
To keep it from repeating, add
Code: background:url(images/bg3.png) no-repeat static;
tyguy87



Joined: 13 Nov 2009
Posts: 4

Posted: Sat Nov 14, 2009 9:43 pm      

Well this page works exactly as I want it to in Firefox:

http://www.greenimprovementsllc.com/attic.html

But in IE8 the content displays below the background image. Do you know if there's a way to make IE8 display everything the same way Firefox does?
sticks464



Joined: 31 Dec 2006
Posts: 2627

Posted: Sat Nov 14, 2009 10:30 pm      

With this div containing the background image
Code: <div id="page-background"><img src="images/bg3.png" width="100%" height="100%"></div>
it is on top of all other content.
Try adding z-index:1 to the container div or remove the page-background div and apply the background to the body.
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum -> General HTML
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group