Background-attachment: fixed not working on android/mobile

吃可爱长大的小学妹 提交于 2019-12-30 03:21:06

问题


I'm developing a cordova app and I'm trying to get a fixed background. Unfortunately, it doesn't seem to be working, and anytime I scroll down the background simply goes off the top of the page. Here's the CSS I'm using to do this (and I've tried it several other ways):

html {
    width:100%;
    height: 100%;
    background-color:#000000;
    background-image:url('../img/bg_reader.jpg');
    /*background-repeat:no-repeat;
    background-attachment: fixed;
    background-position: center;*/
    background-size: 100% 100%;
}

No matter what, the background scrolls off the top of the screen when I scroll down as if the fixed property weren't set.


回答1:


Have you tried this?


    html, body {
        height: 100%;
    }
    html {
        overflow-y: hidden;
    }
    body {
        overflow-y: scroll;
        background-color:#000000;
        background-image:url('../img/bg_reader.jpg');
    }



来源:https://stackoverflow.com/questions/17664927/background-attachment-fixed-not-working-on-android-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!