Yochai Timmer
Yochai Timmer

Reputation: 49251

How can I stretch background on the whole window?

I'm trying to stretch the background to fill the whole window with HTML/CSS.
I've seen a few solutions for this but they don't work.
Every solution i encounter won't work on all the browsers, either Chrome won't stretch it, or IE won't stretch it, and if they both do, firefox will be the problematic one.

Does anyone have a working solution, that will work on all browsers ? (don't mind some javascript)

Upvotes: 2

Views: 257

Answers (4)

Matt
Matt

Reputation: 7160

I believe there is no way to do this without creating an img element, and setting its z-order to the bottom and then customizing the width of that. This page has details.

Edit: In the link it says to use position: fixed;. This will in only work in older versions of IE if you specify a doctype. Using absolute is a simple workaround as long as the element is a direct child of the body.

Upvotes: 1

NewUser
NewUser

Reputation: 13333

write a css for that in which the background image will be in body.like

body {
    background-image: url("/images/bg.jpg");
    background-repeat: no-repeat;
    background-position:center top ;
     }

This will keep the total image in the body.Try this hope it will work.

Upvotes: 0

reisio
reisio

Reputation: 3242

http://reisio.com/temp/stretch/

Upvotes: 1

FlightOfGrey
FlightOfGrey

Reputation: 355

I had this problem a little while ago and I found that this website http://webdesign.about.com/od/css3/f/blfaqbgsize.htm had a very nicely written tutorial which explains it well, plus it worked for what I was looking for.

Upvotes: 1

Related Questions