为什么背景图片在移动设备上不改变?

时间:2018-12-09 12:02:00

标签: html css

html {
    margin: 0;
    padding: 0;
    background-image: url("./Images/mainPage.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

@media only screen and (max-width: 750px) {
    html {    
        background-image: url("./Images/smalMainPage.png");
    }
}

不带“ @media only ...”的部件在屏幕尺寸小于750px的设备上工作。为什么会这样?

1 个答案:

答案 0 :(得分:1)

<meta name="viewport" content="width=device-width, initial-scale=1.0">

标签可能会丢失?因为正在使用Codepen:https://codepen.io/dgknca/pen/REwKrV