CSS: Stretching image to 100% width

后端 未结 2 1095
孤街浪徒
孤街浪徒 2020-12-16 15:04

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?



        
相关标签:
2条回答
  • 2020-12-16 15:59

    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
    0 讨论(0)
  • 2020-12-16 16:06

    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.

    0 讨论(0)
提交回复
热议问题