Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replicate background-attachment fixed on iOS [duplicate]

Tags:

html

css

ios

I'm trying to get fixed-background-image divs working on iOS for a school project. I've been using

background-attachment: fixed; 

But this is leading to weird sizing and no scrolling effects in mobile safari. Here is the site that I'm working with; the method I'm currently using for the quote div image backgrounds works well on desktops but fails completely on iOS.

Somehow, http://www.everyonedeservesgreatdesign.com got this working. I'm having difficulty following the code because they're using a squarespace template of some kind, but it looks like they're putting images into a position:fixed div that is somehow being clipped by its position:relative parent div. I was under the impression that it wasn't possible to clip position:fixed divs with anything other than the viewport, so I'm very curious as to what's going on here.

Any ideas on how to implement this method for fixed image div backgrounds in my site?

like image 227
QRohlf Avatar asked Apr 23 '14 06:04

QRohlf


1 Answers

It has been asked in the past, apparently it costs a lot to mobile browsers, so it's been disabled.

Check this comment by @PaulIrish:

Fixed-backgrounds have huge repaint cost and decimate scrolling performance, which is, I believe, why it was disabled.

you can see workarounds to this in this posts:

Fixed background image with ios7

Fixed body background scrolls with the page on iOS7

like image 153
fernandopasik Avatar answered Sep 20 '22 13:09

fernandopasik