Can a background image be larger than the div itself?

前端 未结 9 1363
天命终不由人
天命终不由人 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:47

    Using background-size cover worked for me.

    #footer {
        background-color: #eee;
        background-image: url(images/bodybgbottomleft.png);
        background-repeat: no-repeat;
        background-size: cover;
        clear: both;
        width: 100%;
        margin: 0;
        padding: 30px 0 0;
    }
    

    Obviously be aware of support issues, check Can I Use: http://caniuse.com/#search=background-size

提交回复
热议问题