Forum Moderators: not2easy
I'm a bit stumped with how to create a centered div that is position: absolute, with a fixed width, and a repeating background. I have no problems with Safari or Mozilla, but IE doesn't like either of my attempts.
What I've read and tried is as follows:
1) Using two divs with a parent/child relationship.
#topParent{
position: absolute;
width; 750px;
margin-left: 50%;
top: 0;
}
#topChild{
margin-left: -384px;
height: 103px;
width: 768px;
background: url(/images/bg.gif);
background-repeat: repeat-y;
text-align: left;
}
#top{
position: absolute;
top: 0;
margin: 0 auto 22px auto;
height: 103px;
width: 768px;
background: url(/images/bg.gif);
background-repeat: repeat-y;
text-align: left;
}
The unfortunate thing is that either of these methods work fine for both Moz and Safari. Neither work for IE. :/
Any suggestions? Am I doing something wrong here?
Thanks,
Chris
#top{
position: absolute;
left: 50%;
top: 0;
margin-left: -384px;
height: 103px;
width: 768px;
background: url(/images/bg.gif);
background-repeat: repeat-y;
text-align: left;
} I think so anyway...
#top{
position: absolute;
top: 0;
left: 50%;
margin-left: -384px;
height: 103px;
width: 768px;
background: url(/images/bg.gif);
background-repeat: repeat-y;
text-align: left;
}
using both the left co-ordinate to center it and then the negative left margin ~ half the width value to move it back (outdent) it again.
Suzy
I've encountered a new problem in that IE for Mac seems to be caching the external stylesheet? Is this even possible?
What I've found works best so far (IE 6.x, Moz, & Safari) is the following:
#top{
position: absolute;
top: 0;
left: 50%;
width: 768px;
margin-left: -384px;
height: 103px;
background: url(/simages/bg.gif);
background-repeat: repeat-y;
text-align: left;
}
I've taken #top out of the flow because I'd like for my content to appear first on the page. Basically the pseduo for the html page is as follows:
Container (margin top = 100px)
Content (Float right)
Navigation (Float Left)
Footer (Clear Both)
Container Close
Header (Absolute to Top & height 100px)
When I remove the stylesheet the HTML displayed is very pretty.
I've done similar things before for simple sites but I didn't worry about centering the container & set a min-height/height value equal to the height of the nav menu.