1

I have a div with a background image applied dynamically with JS. It works great except in iOS - both in iOS Safari & iOS Chrome, the background image just doesn't show. Very weird I didn't find any answer for that online. Here is how it looks normally:

enter image description here

And here it how it looks on iOS (ipad and iphone):

enter image description here

Here is the CSS, the background-image value was applied by JS:

.NavFrame {
  width: 104px;
  height: 58px;
  background-position: center center;
  background-size: cover;
  margin-right: 2%;
  background-image: url(http://www.test.com/test.jpg);
}

Any help will be appreciated.

UPDATE: Thank you all for the answers, however eventually it was some bug in my JS code. Anyway hope it can help someone else.

Light
  • 1,647
  • 3
  • 22
  • 39
  • This issue is already discussed in stackoverflow pl. refer to the below link http://stackoverflow.com/questions/18999660/background-image-not-showing-on-ipad-and-iphone – shri Jun 09 '15 at 12:06

3 Answers3

1

try like this

.NavFrame {
      width: 104px;
      height: 58px;
      background-position: center center;

      margin-right: 2%;
      background-image: url(http://www.test.com/test.jpg);
      background-size: cover; 
    }
1

Set the background-size after background-image:

.NavFrame {
  width: 104px;
  height: 58px;
  margin-right: 2%;
  background-image: url(http://www.test.com/test.jpg);
  background-position: center center;
  background-size: cover;
}

Or shorthand:

.NavFrame {    
  background: url(http://www.test.com/test.jpg) center center / cover;
}
Tony Barnes
  • 2,625
  • 1
  • 18
  • 29
0

This issue is already discussed in stackoverflow pl. refer to the below link Background image not showing on iPad and iPhone

Community
  • 1
  • 1
shri
  • 856
  • 1
  • 10
  • 26