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:
Try setting your header to height: 100% . Alternatively (the better solution), set the background on the body if you want it to cover the whole page.
If the background-size is contain or cover : While preserving its intrinsic proportions, the image is rendered at the largest size contained within, or covering, the background positioning area. If the image has no intrinsic proportions, then it's rendered at the size of the background positioning area.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With