The second image box is not static. It uses JS to have the images fading in and out and alternating. The above CSS did not work - the image refused to move from top left of the containing div.
I eventually got the image/s centred with the current CSS which is far more extensive:
This centres the image/s and is fine in FX and IE8 but in IE7, the image is in the top left of the containing div. Have tried all sorts of different settings to no avail - it just won’t shift over.
I was wondering if there is a conditional comment I can use for IE7 or perhaps someone can let me know why this is happening. I have added “text-align: center” to the body just in case.
Margin :auto doesn’t work on absolute elements in iE6 and 7
It works in good browsers and is a little known fact but you need to also set the left and right positions at the same time and for the element to have a width.
Damn I was just recently trying to automargin some abso-po’d boxes and it wasn’t working so I figured it doesn’t work for them… now I know why it wasn’t.
Thanks for reply, Ryan but it didn’t work. All browsers show half an image fixed to the left hand side of containing div so I have restored the original CSS which at least works in all but IE7. Will try some other centering options if I can think of any I haven’t already tried.
Ryan - my colleague seems to have fixed it by adding another div round the fading images div. Seems to be OK now in IE7. Thanks for the help. Did you see anything in the original CSS that was causing the issue?
I think our posts went up at the same time!
Margin :auto doesn’t work on absolute elements in iE6 and 7
It works in good browsers and is a little known fact but you need to also set the left and right positions at the same time and for the element to have a width.
The trick is the left:0 and right:0 which would normally mean the element is 100% wide but because it has a width already defined then the auto margins can centre it within that original left:0 and right:0 space.