I would like to have a background image on a website. This seems like a pretty reasonable request.
I want the background image to be in a fixed position, so that the content scrolls over the top of it. On a classic desktop browser, you can use something like background-attachment: fixed
, but this has no affect on my small touch screens. Instead the image scrolls along with you.
It would be great if I could have a position: fixed
div with the background image - could accomplish this... but then there is another issue where the 'chrome' or the UI for these touch/small-screen browsers / changes the size of the view-port to accommodate it's buttons - and then again when you scroll down + the buttons go away and the viewport is now taller. (this is not a new problem, but it seems like a problem everyone is OK with.) I am wondering if I'm missing some other option / . I've been trying to find a way around this for years.
<div class='background'></div>
.background
background-image: url('some-image.jpg')
position: fixed
top: 0
right: 0
bottom: 0
left: 0
http://codepen.io/sheriffderek/pen/pbQpwp
Debug view for phone: http://s.codepen.io/sheriffderek/debug/pbQpwp