Andy Dwyer
Andy Dwyer

Reputation: 716

CSS div background image help

I want to have a CSS div that has a background image (the full image size is 950px x 306px), that shows the entire background image, and that adjusts the sizing of the background image depending on the browser size.

So the CSS div code should:

Can someone please help with this? I'm really new to CSS and have been trying many different methods but none seem to work. I really appreciate your help!

P.S. No JQuery please :)

Upvotes: 0

Views: 2896

Answers (3)

Jason Gennaro
Jason Gennaro

Reputation: 34863

You could do this.

body{margin:0; 
    padding:0; 
    width:100%; 
    height:100%; 
    overflow:hidden;
}

img#background{position:absolute; 
    z-index:1; 
    width:100%; 
    height:100%;
    top:0; 
    left:0;
}

http://jsfiddle.net/jasongennaro/nTLXA/1/

Then position divs on top of this.

Upvotes: 0

Dee
Dee

Reputation: 255

If you want it to resize for the user's browser, it'll have to be dynamic. You cannot do that with CSS alone.
This may be of use: http://imageresizing.net/

Upvotes: 1

trutheality
trutheality

Reputation: 23465

body
{
background-image:url('image.gif');
background-size:100% 100%;
}

Upvotes: 3

Related Questions