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

后端 未结 4 1448
深忆病人
深忆病人 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:43

    You need to set the height of html to 100%

    body {
        background-image:url("../images/myImage.jpg");
        background-repeat: no-repeat;
        background-size: 100% 100%;
    }
    html {
        height: 100%
    }
    

    http://jsfiddle.net/8XUjP/

提交回复
热议问题