如何设置固定位置背景图像在jquery移动为iPhone应用程序使用Phonegap [英] How can I set fixed position Background image in jquery mobile for iPhone app using Phonegap

查看:117
本文介绍了如何设置固定位置背景图像在jquery移动为iPhone应用程序使用Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Phonegap&也使用jquery mobile。我想为data-role = page div设置背景图片。在这个页面的高度等于屏幕&因此背景被设置为屏幕的大小。但是页面内容长度远大于屏幕&因此在图像完成后看到灰色背景。
我的问题是,是否有一种方式,使我们可以保持背景图像固定&仅滚动或移动页面&不是背景图像。
只是提到我试过全尺寸背景jquery插件。它在Android上运行,但不在iOS上运行。

I am doing a iPhone app using Phonegap & also using jquery mobile. I want to set background image for data-role=page div. In this height of page is equal to screen & hence background is set to size of screen. But the page content length is much greater than screen & hence gray background is seen after image completes. My question is whether there is a way so that we can keep the background image fixed & scroll or move only content of page & not background image. Just to mention I have tried full size background jquery pluggin. Its working on Android but not on iOS.

任何人都可以帮忙吗?提前感谢。

Can anyone please help? Thanks in advance.

推荐答案

好的,所以我做的是在页面的body元素中创建一个固定的元素。
所以它看起来像

Ok, so what I did instead was to create a fixed element within the body element of the page. So it would look like

<body>
   <div id="background"></div>
    ...
</body>

对于CSS,我说了以下内容:

And for the CSS I stated the following:

    #background {
    position:fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background: url(images/bg-retina.jpg) 0 0 no-repeat fixed !important;
    background-size:contain;
}

希望它有帮助(有人在那里:P)

And this did the trick for me. Hopefully it helps (someone out there :P)

这篇关于如何设置固定位置背景图像在jquery移动为iPhone应用程序使用Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆