Is it possible to make a responsive div with a background-image that maintains the ratio of the background-image like with an ?

后端 未结 5 428
-上瘾入骨i
-上瘾入骨i 2021-01-31 12:30

Not a a native english speaker so there\'s probably a better way to shape the question...anyway:

What I want to create is similar to the header here: http://thegreatdisc

5条回答
  •  温柔的废话
    2021-01-31 13:24

    Although there are other solutions. % will scale the div to image size or the aspect ratio.

    .responsive-image{
    width: 100%;
    background-image: url(x.jpg);
    background-repeat:no-repeat;
    background-size: 100% 100%;
    

    }

提交回复
热议问题