Page 1 of 1

Background images stretched

Posted: Tue Mar 07, 2006 11:55 pm
by alex.barylski
How can I accomplish this?

Does CSS support background-image stretching???

I know how to set a background image: background-image: url('test.jpg')

But can I make it so a 600x800 background image is stretched like a desktop to fit the available screen size accordingly?

Can I use javascript to accomplish this without a IMG tag?

I need this image to no dought always be in the background and other HTML to layout normally overtop and i'm not keen on using an IMG tag and setting it's z-index to -1 or something similiar...

I've tried this with other tags and it caused problems...like FORM elements not getting focus, etc...

Thanks a ton :)

Posted: Wed Mar 08, 2006 12:19 am
by Benjamin
You can try setting the width of the image in css to a percentage but not all browsers may support that. It might be better to use Javascript.

Posted: Wed Mar 08, 2006 1:05 am
by feyd
As far as I know, it's not possible without an <img> tag sadly. Everytime I've needed to do this sort of thing, it's been an <img> .. although I avoid needing to do the stretch as much as possible in applications.