全屏背景图片不随内容滚动 html5 phonegap

Fullscreen background image not scrolling with content html5 phonegap

我有一个整页背景图片,代码如下:

<html class="full" lang="en">
    <body class="full" >    
             header, footer and content.... Extending beyond the initial view.
        </body>
</html>

<style>   
.full {
  background: transparent url(../img/blur-background.jpg)  no-repeat 0 0 fixed; 

  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
</style>

我的问题描述是,

以下是画面

原创 - 全屏背景

滚动时部分白色背景

滚动后出现的屏幕背景。请注意,原始背景未扩展。背景图片再次starts/repeats。

我会为您的背景提供明确的 div,例如:

<html>
    <body>
    <div id="homeScreenBG"></div>
<div id="restOfPage">
             header, footer and content.... Extending beyond the initial view.
</div>
        </body>
</html>


#homeScreenBG {
position: fixed;
background-repeat: no-repeat;
width: 100%;
height: 100%;
    background-image: transparent url(../img/blur-background.jpg)  no-repeat 0 0 fixed;
    -webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover; background-size: cover;
}

终于用CSS和jQuery解决了这个问题。现在完美运行了。

mypage.html

<link rel="stylesheet" type="text/css" href="css/full-screen.css" />
<script type="text/javascript"  src="js/full-screen.js"></script>

<div data-role="page" data-cache="false">
    <div data-role="header">
    </div>
    <div  class="ui-content"  data-role="content">

        <!-- All content here....... Scrollable content here.... -->
    </div>
    <div data-role="footer">
    </div>
</div>

全-screen.css

body {
    margin-top: 50px;
    margin-bottom: 50px;
    background: none;
    background-attachment:fixed;  
    border: 0px;
}


.ui-page {
    background-color: #373737 !important; /*Any color based on the data-theme selected*/
}

.ui-content {
    background: transparent url(../img/blur-background.jpg);
    background-size : 100% 100%;
}

全-screen.js

$(document).on("pageshow", function(){
     SizeContent();
});
$(window).on("resize orientationchange", function(){
    SizeContent();
});

function SizeContent(){
    var screen = $.mobile.getScreenHeight();
    var header = $(".ui-header").hasClass("ui-header-fixed") ? $(".ui-header").outerHeight() - 1 : $(".ui-header").outerHeight();
    var footer = $(".ui-footer").hasClass("ui-footer-fixed") ? $(".ui-footer").outerHeight() - 1 : $(".ui-footer").outerHeight();
    var contentCurrent = $(".ui-content").outerHeight() - $(".ui-content").height();
    var content = screen - header - footer - contentCurrent;
    $(".ui-content").height(content);
}