I have a css like this:
#thumbnail {
background-image: url(bla.jpg),
background-size: cover,
background-repeat: no-repeat;
background-position: 50% 50%;
}
It is showing fine on iOS Safari and everywhere else. However, when I "Add to Home Screen" the page, the image will not be shown.
What I tried (with no luck):
Using
background-size: contain
Using JavaScript to "lazy load" the background-image.
Dynamically appending it as an
<img>
instead of a background-image using JavaScript.Adding it straight into HTML document. It starts displaying but does not obey any CSS style, even after I try it with JavaScript styling, and with
width
andheight
attribute (why?).Using
background-position: top center
instead of50% 50%
.Using other image format such as
.png
.Applying background-image to
::after
pseudo-element like below:#thumbnail::after { content: ''; display: block; padding-top: 100%; background-image: url(...), background-size: cover, background-repeat: no-repeat; background-position: 50% 50%; }
It just doesn't work properly.
I searched StackOverflow and Google for the same problem, none facing the same issue as most of them are referring to problems in Safari browser and non-supported CSS property (which isn't the problem in my case).
Does anyone know what could be the problem and how to solve it?
This problem only occur after "Add to Home Screen". It works perfectly fine in iOS Safari browser and iOS Chrome browser.