sandalone
sandalone

Reputation: 41779

Keep background-size: cover, but also enable size auto for iphones?

In the CSS style file I have this line

background-size: cover;

But then the background image will not be visible on iPhones. All other phones can see it.

And then if I set size like this

background-size: auto;

all mobile devices + iPhone can see the background, but the web is the weird. The image does not size well, but you can see some spacing between the image and its container.

What is the proper way to solve this situation?

Upvotes: 0

Views: 60

Answers (1)

sdr981
sdr981

Reputation: 405

Try this:

.backgroundImage { position: fixed; top: 0; left: 0; min-width: 100%; min-height: 100%; }

https://codepen.io/anon/pen/YQmEQw

Upvotes: 1

Related Questions