This is my code:
background-color:#fff;
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-position: center center;
It's working on desktop, iPad and Android mobile:
On Chrome and Safari on iPhone, the background is too big:
This happens, particularly on iOS, when you have background-attachment:fixed
. On mobile, I usually put background-attachment:scroll
inside of a @media
query.
As @RyanKimber pointed out, fixed attached images use the whole <body>
size. On mobile this can get really tall which blows your image out. Setting the attachment back to scroll
allows your cover image to stretch within its own container.