Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Resize background image to browser size?



4:23 pm on May 29, 2012 (gmt 0)


Please can someone help me out, I am a newbie when it comes to CSS and have been trying to learn as much as possible online.

I have a background image that I am trying to make it resize when the browser window gets smaller or bigger.

I have seen the right code online but do not know how to implement it into my own code.

This is what I have at the moment.

* { margin:0; padding:0;}
body {
font-family:Arial, Helvetica, sans-serif;
padding:29px 0 33px 0;
background: url("../images/body-bg.jpg");
background-attachment: fixed;
background-repeat: no-repeat;
background-size:height 100% width 100%;

I have tried adding the code to this but I just cannot get it to work.

It would be much appraised if someone could help me out with this.


[edited by: alt131 at 9:55 pm (utc) on May 29, 2012]
[edit reason] Thread Tidy [/edit]


10:55 pm on May 29, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Try changing to
background: url(../images/body-bg.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
-moz-background-size:100% 100%;
background-size:100% 100%;

Read more here CSS3 Backgrounds [w3schools.com]



11:07 pm on May 29, 2012 (gmt 0)

Thank you so much!

Huge help!


12:09 am on May 30, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You're welcome :)


Featured Threads

Hot Threads This Week

Hot Threads This Month