Stretch and scale CSS background

前端 未结 16 2002
难免孤独
难免孤独 2020-11-22 02:28

Is there a way to get a background in CSS to stretch or scale to fill its container?

16条回答
  •  一向
    一向 (楼主)
    2020-11-22 02:55

    Try the article background-size. If you use all of the following, it will work in most browsers except Internet Explorer.

    .foo {
        background-image: url(bg-image.png);
        -moz-background-size: 100% 100%;
        -o-background-size: 100% 100%;
        -webkit-background-size: 100% 100%; 
        background-size: 100% 100%;
    } 
    

提交回复
热议问题