Forum Moderators: not2easy

Message Too Old, No Replies

Positioning header images

         

alex22

1:50 am on Jan 27, 2011 (gmt 0)

10+ Year Member



Hello,

I have a homepage with the following code:

...
<body>
<center>
<div id="header">
<div id="headerimg"></div>



<div id="menu_top"></div>
<div id="menu_top_img"></div>
...

and a css file with the classes as following:

#header {
background-color: #FFFFFF;
width: 860px;
border: 0px #ffffff solid;
overflow: hidden;
}

#headerimg {
background: url(images/xx.jpg)
no-repeat;
z-index: 1;
height: 120px;
width: 800px;
position: relative;
}

#menu_top {
z-index: 1;
position: relative;
}

#menu_top_img {
background: url(#*$!.jpg)
no-repeat;
z-index: 3;
width: 800px;
height: 100px;
margin-left: 0px;
margin-top: 42px;
position: absolute;

}


the problem is the difeference between viewing the website in IE or firefox.

the image in the class menu_top_img is always messed up by 30px, I think its because of the element flow in both browsers, once the image is centered in IE and too far on the left in FF, with margin-left: 0px;

If i change the margin-left to 30px the image in FF is just fine and the image in IE is 30px too far on the right.

Would be really thankful for any help, Alex

Fotiman

2:24 pm on Jan 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld!
Differences between IE and Firefox can layouts can often be attributed to IE being in Quirks mode. Are you using a DOCTYPE that triggers quirks mode?

Also, when you position absolutely, you should specify the "top" or "bottom" and the "left" or "right".

alex22

7:10 pm on Jan 27, 2011 (gmt 0)

10+ Year Member



i worked a little bit with DOCTYPES but it seems to not change anything with this problem.

i use "margin-left" instead of "left" because the absolute image is then scrollable (which i need it to be), if i use the other position options then the element is in the normal element flow of HTML, and i dont want it to be in the normal elements flow because if i move the image there is a space where the image was before which i dont need, maybe there is a simple solution for that which I havent found yet.