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

后端 未结 5 433
-上瘾入骨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:19

    I think theres a better solution than contain or cover (which dind't work for me, btw). Here's an example I recently used for a logo:

    #logo{
        max-width: 600px;
        min-height: 250px;
        margin: 0 auto;
        background: url(../images/logo.png) no-repeat center;
        background-size: 100%;
    }
    

    So now we have a responsive div with a backgound image, which size is set to the full width of the div.

提交回复
热议问题