How to set a minimum width with background-size

后端 未结 4 538
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 06:46

I have an image that is 1000px X 600px . I want to use it as a responsive background for a div but would like to set a minimum width of 1000px despite how small the browser

4条回答
  •  有刺的猬
    2021-01-04 07:11

    I had the same problem. The following code worked for me. I just had to add a min width in the same element. Here I just used the html element, I would assume that it would be more conventional to use the body element

         /* CSS Style Sheet */
    
     html    { background-image:url(example.JPG);
                        background-size:cover;
                        min-width:1000px;}
    

    I hope this helps,

提交回复
热议问题