Full Screen Background Image Is Stretched

后端 未结 6 1256
我在风中等你
我在风中等你 2021-01-07 02:58

I had made a full screen background image for one of my clients, but the problem is that when I make the image to fit all the screen using the following css codes:

6条回答
  •  庸人自扰
    2021-01-07 03:23

    You should really look into the background size property instead of using fixed images. Using 'cover' for background-size, means that the image should grow or shrink just enough to cover the whole background.

    If you know the dimensions of the image. You can use a media query to change the background-size to 'auto' when it would otherwise grow beyond it's original size.

    html, body {
        min-height: 100%;
    }
    body {
        background-image: url(http://leydenlewis.com/images/LANDING_PAGE.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-size: cover;
    }
    @media (min-width: 1120px), (min-height: 630px) {
        body { background-size: auto; }
    }
    

提交回复
热议问题