My CSS code looks like this:
#thumbnail {
background-image: url(bla.jpg),
background-size: cover,
background-repeat: no-repeat;
background-position: 50% 50%;
}
While it displays fine on iOS Safari and other platforms, the image does not show up when I "Add to Home Screen" the page.
Here are a few things I've tried without success:
Using
background-size: contain
Attempting to "lazy load" the background-image using JavaScript.
Dynamically appending the image as an
<img>
instead of a background-image with JavaScript.Adding the image directly into the HTML document makes it display but ignores any CSS styling applied to it, even after adjusting with JavaScript and setting
width
andheight
attributes (why?).Trying
background-position: top center
instead of50% 50%
.Experimenting with different image formats such as
.png
.Applying the background-image to the
::after
pseudo-element as shown below:#thumbnail::after { content: ''; display: block; padding-top: 100%; background-image: url(...), background-size: cover, background-repeat: no-repeat; background-position: 50% 50%; }
None of these solutions seem to work properly.
I've searched both StackOverflow and Google for similar issues, but most references relate to problems in Safari browser or unsupported CSS properties, which doesn't appear to be my case.
If anyone has insights on what might be causing this issue and how to resolve it, I would greatly appreciate the help.
This problem specifically arises after using "Add to Home Screen". It functions perfectly well in iOS Safari and iOS Chrome browsers.