Can a background image be larger than the div itself?

前端 未结 9 1301
天命终不由人
天命终不由人 2020-12-12 20:37

I have a footer div with 100% width. It\'s about 50px high, depending on its content.

Is it possible to give that #footer a background image that kind of overflows t

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 20:46

    There is a very easy trick. Set padding of that div to a positive number and margin to negativ

    #wrapper {
         background: url(xxx.jpeg);
         padding-left: 10px;
         margin-left: -10px;
    }
    

提交回复
热议问题