jQuery Mobile background image not showing on a fu

2020-07-23 08:19发布

I have set a background on the data-role="page" element like so

<div data-role="page" style="background: transparent url('img/background.jpg') no-repeat;" >

It works perfectly fine on a desktop browser and on the iPad safari browser.

The issue I am having is that when you add the website to the home screen as an 'app' and it is a full screen web app. It doesn't show the background...

I have tried setting it via a style sheet and inline and both ways give me the same issue.

I am completely out of ideas as to why this wouldn't work.

Any ideas are greatly appreciated.

5条回答
爷的心禁止访问
2楼-- · 2020-07-23 08:45

In your CSS file:

[data-role=page] {
    background: transparent url('img/background.jpg') no-repeat;
}
查看更多
萌系小妹纸
3楼-- · 2020-07-23 08:50

Create a css class and end every attribute with !important to over-rule framework css. Thats why it is working inline only

查看更多
forever°为你锁心
4楼-- · 2020-07-23 08:56

Try with this

<style type="text/css">
.ui-page 
{

    background-image: url("img1.jpg");
    background-attachment:fixed;
    background-repeat: no-repeat;
    background-size: 100%;
}
</style>
查看更多
虎瘦雄心在
5楼-- · 2020-07-23 08:57

Apply this to the element:

.#target-element {
    background : transparent url(YOUR_URL) 0 0 no-repeat fixed !important;
    background-size : cover;
}​
查看更多
Lonely孤独者°
6楼-- · 2020-07-23 09:07

In the end this is what worked for me.

<div data-role="page" id="home" style="background: #000000 
    url('img/background.jpg') repeat;">

wouldn't work via a css file.

查看更多
登录 后发表回答