CSS: stretching background image to 100% width and height of screen?

后端 未结 4 1447
深忆病人
深忆病人 2020-11-29 03:19

I have an image called myImage.jpg. This is my CSS:

body {
    background-image:url(\"../images/myImage.jpg\");
    background-repeat: no-repeat;
    backgro         


        
4条回答
  •  日久生厌
    2020-11-29 03:38

    The VH unit can be used to fill the background of the viewport, aka the browser window.

    (height:100vh;)

    html{
        height:100%;
        }
    .body {
         background: url(image.jpg) no-repeat center top; 
         background-size: cover; 
         height:100vh;     
    }
    

提交回复
热议问题