I’m trying to set up a manualy splash-image across devices. I’m doing so by checking for orientation (touch devices) or screen width vs. screen height (none touch) and set a url accordingly.
Then I add this CSS rule via Javascript:
document.styleSheets[3].insertRule('.initHandler:before {
background: url('+x+') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}', 0)
With x being the image to be loaded depending on orientation and screen size.
My problem is this works fine in landscape mode, but on my iPad in portrait mode, the correct image is loaded (differ depending on portrait/landscape), BUT it is not expanded to fullscreen size.
Question:
Can I not use CSS background-size on iOS in portrait-mode?
Thanks for help!
EDIT:
Just tried on my Android Smartphone. Works fine there. Makes no sense, why it doesn’t work on iPad.
While checking orientation please take note of these points from apple document –
and
So we can overcome that limitation by setting the background-size to 100% width or height, depending on the orientation. We can target the current orientation (as well as the iOS device, using device-width). With these two points I think you can use CSS
background-size:coveron iOS in portrait-modeHere are some other resources I also came across while looking for a solution: Flexible scalable background images, full scalable background images, perfect scalable background images, and this discussion.