CSS: Stretching image to 100% width

Hi all I am trying to strech the background of my side to fit the width. I only found big workarounds in the internet. Is there not one single command for this?

body {
    background-image: url(money.jpg); 
}

Thanks for the answers. Doonot


Use background-size like the one used below,

body {
  background-image: url(money.jpg) no-repeat;
  background-size: 100%;
}  

Some useful links :

  • Scale background image style
  • Stretch and Scale a CSS image Background - With CSS only

  • If you have a CSS3 browser you can use background-size (read more about background-size):

    body {
        background-image: url(money.jpg); 
        background-size: 100%;
    }
    

    Unfortunately this won't work in IE 6-8. IE 9, Firefox, Chrome, Safari it will work fine.

    链接地址: http://www.djcxy.com/p/89230.html

    上一篇: 如果图像的宽度比其容器更宽,我该如何居中放置图像?

    下一篇: CSS:将图像拉伸至100%宽度