views:

33

answers:

2

I need to be able to stretch a image background to fit the window size now it works in all browsers except for ie6 I have endlesly searched the internet for a solution and tried all things I have found but nothing seems to work in ie6

here is my demo site if you have ie6 you will be able to see my problem I need it too stretch the full width and height with out it distorting the image at all

http://demo.jigsawfinance.com/

any one know a solution that will work I have the img tag etc but still no avail

for those without ie6 here is a capture of the screen veiw

alt text

as you can see I have alot of white space where the image is supposed to expand too

+1  A: 

Have a look at this: http://stackoverflow.com/questions/1150163/stretch-and-scale-a-css-image-background-with-css-only

also this layout seems to work in IE6: http://www.cssplay.co.uk/layouts/background.html

Moin Zaman
thankyou i had looked at this previously it does not work for me in ie6 :(
sam
that just places the image in the center but not the whole background
sam
but it distorts the image which cannot happen but thankyou
sam
did you try the second link?
Moin Zaman
yes i tried both the second one kind of works but it distorts the background
sam
how can you fill the whole browser but not alter the aspect ratio of the image? i.e either the image has to distort, or the image has to stretch one dimension to fit either width or height and the other to be larger and get cut off.
Moin Zaman
+1  A: 

There is a way for CSS 3 to do this but since IE6 does not support it, I think your best bet is to use the img tag.

e.g.

<img src="../images/jigsaw_logo.png" style="width: 100%; position: absolute; top: 0; left: 0; z-index: -1;"/>

This will retain the proportion of your image and move it back.

Also take note that in IE's css, you can specify expressions, so try the one below if you're having trouble with the normal 100% css width:

width: expression(document.body.clientWidth + 'px');
Manny
thanks i just tried that but still ie6 it does not stretch the img to full size of the window :(
sam
can you try on a clean html? What do you mean full size of the window? The image does not stretch at all? This can be caused by margins / paddings. I tried it in IE6 and it works.
Manny
ok it works in a clean sheet but i have a red cross in the corner i dont understand why it wont work on my pages?
sam
ok it works but if you move the window from the side the image shrinks back to its origanal size
sam
adding height 100% fixes that but then it distorts the image :S
sam
height 100% will surely distort the image. Where did you add the image, try adding it directly after the body tag. E.g. </head><body class="HomeIndex"> <!-- put the image here!!!!/--> <div id="container">
Manny
i tried adding min-width and min-height too but ie6 doesnt seem to render this
sam
this is where i placed it <head> <title>Home</title> </head><body><img src="../images/bg.jpg" style="width: 100%; position: absolute; top: 0; left: 0; z-index: -1; "/></body></html>
sam
has no effect in ie6 when i add it to my real page either
sam
add <body style="margin: 0"> for ie6 to remove the margins.
Manny
stretched it about 10pixels maybe the img seems to expand to the size of the actual container only
sam
In you clean html, the container is the body right? Then try to use <body style="margin: 0; width: 100%; height: 100%">
Manny
nope as soon as i resize the window from the side the image shrinks in height and leaves alot of white space
sam
Is your browser's autoresize ON ? Tools -> Internet Options - > Advanced tab -> under Multimedia -> Enable Automatic Image Resizing
Manny
yes its switched on
sam
ok i guess i will take your way and work around the bit of white space at the bottom until i find a better solution thankyou for your time today
sam
ok i cant seem to get it to work in my actual site in ie6
sam
but i think its something to do with my css
sam
it appears to be the my container width that stops it from expanding to full wiondow size
sam
take note that in IE, you can also force expressions e.g. width: expression(document.body.clientWidth + 'px'); <-- this will force the image's width to expand.
Manny
thankyou that worked :)
sam