【问题标题】:Fullscreen background image not scrolling with content html5 phonegap全屏背景图像不滚动内容html5 phonegap
【发布时间】:2015-04-28 10:50:48
【问题描述】:

我有一个带有以下代码的整页背景图片:

<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>

我的问题描述是,

  • 最初全屏背景图片在安卓手机中呈现。 [没问题]
  • 但是当我滚动时,背景图像没有出现。而是出现白色背景。 [问题]
  • 如果我单击视图中的某些控件,会重新出现原始背景。就我而言,复选框。 [问题]

下面是屏幕

原始 - 全屏背景

滚动上的部分白色背景

滚动后出现的屏幕背景。请注意,原始背景未扩展。背景图像再次开始/重复。

【问题讨论】:

    标签: android css html cordova jquery-mobile


    【解决方案1】:

    我会为您的背景使用明确的 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;
    }
    

    【讨论】:

      【解决方案2】:

      最后通过使用 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>
      

      full-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%;
      }
      

      full-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);
      }
      

      【讨论】:

        猜你喜欢
        • 2013-11-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-31
        • 2018-04-17
        • 2014-09-11
        • 2017-09-30
        • 2023-03-16
        相关资源
        最近更新 更多