Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am trying to create a div with a full background image its working fine in most of the browsers using:
background-size: 100% 100%;

but not IE6,IE7,IE8.
i am wondering how to do it,and if possible using css only?
Posted

The css information for this is available here[^]. Note that IE tends to require custom css at times.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jul-11 12:40pm    
My 5. No, it is not rendered property according the compatibility sheet you reference.
I have an argument in favor of alternative: background-size cause re-sampling anyway, which is already not good.
Please see my solution.
--SA
thatraja 8-Jul-11 23:47pm    
5!
According the compatibility data referenced by Marcus, background-size is not processed properly in the browsers you list.

I don't think you can do anything about it. Not supported means not supported. I would recommend to slightly change design to avoid this style. Why?

The style background-size: 100% 100%; cannot be perfect anyway. Here is why: the causes stretch of the background image, which cause re-sampling. There are problems with any re-sampling in principle: the quality of image depends on the rendered size of the block element (or window) and can cause most ugly pixellation as the stretch grows. Even rendering performance could suffer. Again, you cannot fix compatibility unless you force custom CSS for different browser, which is also a problem.

Therefore I would recommend using background-repeat styles to tile your image. See, for example: http://www.w3.org/TR/CSS2/colors.html[^].

Good luck,
—SA
 
Share this answer
 
Comments
thatraja 8-Jul-11 23:48pm    
5!
Sergey Alexandrovich Kryukov 10-Jul-11 1:00am    
Thank you, Raja.
--SA
vergil135 10-Jul-11 1:37am    
Thanks
my problem requires the stretching and i already have a different css for each browser,moreover the div which the image should fill is not a full page.
the problem is replacing the background-size with an IE compatible alternative.
thanks any way
Sergey Alexandrovich Kryukov 12-Jul-11 15:55pm    
You're welcome. Well, of stretching, you will have to fail to provide it at least for the browsers which do not support it. Try the solution by Espen.
--SA
This may solve your problem: How Do you Stretch a Background Image in a Web Page[^] - even handles IE 6

Best regards
Espen Harlinn
 
Share this answer
 
Comments
thatraja 8-Jul-11 23:48pm    
5!
Espen Harlinn 9-Jul-11 6:18am    
Thank you, thatraja!
Sergey Alexandrovich Kryukov 10-Jul-11 1:00am    
Very interesting article, my 5.
--SA
Espen Harlinn 10-Jul-11 6:43am    
Thank you, Sergey - the IE conditionals will be removed in the next version of IE, from then on they will only work in compatibility mode

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900