【问题标题】:How to Prevent the page background image from stretching in jQuery mobile 1.4.0?如何防止页面背景图像在 jQuery mobile 1.4.0 中拉伸?
【发布时间】:2014-02-28 17:58:11
【问题描述】:

在我的 jQuery mobile 1.4.0 应用程序中,我有一个包含列表视图的页面,问题是当我为此页面添加背景图像时,随着背景随着内容的延伸而变得越来越大,而这在移动设备上比 jsFiddle 更明显,这是我的jsfiddle。

如何使背景图像全屏并固定,而不是随内容拉伸?请帮帮我..

这里我如何将背景图片添加到我的页面:

#EmPListPage{
   background-image: url('http://images2.layoutsparks.com/1/218610/just-ducky-dots-  pinky.gif') !important;
   background-repeat: no-repeat;
   background-size: 100% 100%;
 }

 #PageContent{

   background: transparent ;    
 }

【问题讨论】:

  • 将背景图片添加到页面本身比内容 div 或任何其他 div 更好。
  • @Omar我已经将背景图片添加到页面检查jsfiddle,这个#EmPListPage:是我的页面ID
  • @Omar你对这个问题有什么想法吗?我该如何解决,请您帮帮我吗?
  • 添加 body 并给 .ui-page 一个透明背景。 jsfiddle.net/t9G2h/13
  • @OmarThanks 我已经像这样尝试过jsfiddle.net/t9G2h/14 因为我在 Page 上的内容不止于此,而且每个页面都有不同的 BG,它在 jsfiddle 上工作但对我不起作用!这是因为我使用的是本地目录中的图像吗? Plaese你能帮我更多吗

标签: css jquery-mobile background-image stretch


【解决方案1】:

就我而言,解决方案是使用contain,如下所示:

.ui-page {
    background: #000;
    background-image: url("http://bettingmasters.info/wp-content/uploads/2013/11/19757-football-stadium-1920x1200-sport-wallpaper.jpg");
    background-size: contain;  
}

【讨论】:

    【解决方案2】:

    您需要将背景图片附加到文档 body 而不是容器 div。在小提琴中使用你的 CSS:

    body {
       background-image: url('http://images2.layoutsparks.com/1/218610/just-ducky-dots-pinky.gif') !important;
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
    
    #EmPListPage, #PageContent{    
       background: transparent ;    
    }
    

    小提琴:http://jsfiddle.net/chucknelson/6zKJg/

    【讨论】:

    • 我试过了,但在 jQuery mobile 1.4.0 中根本不起作用背景图片没有出现
    • @user 不确定您是否在 cmets 中解决了这个问题,但我添加了一个小提琴(基于您的最新版本)来证明这个答案似乎在正常情况下有效。也许您的实际代码中存在独特的问题,不确定。
    猜你喜欢
    • 1970-01-01
    • 2012-01-30
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    相关资源
    最近更新 更多