Background images stretched

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Background images stretched

Post 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 :)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply