Prevent fixed-position background-image: cover from resizing in mobile browsers upon address bar hide

前端 未结 6 1650
北海茫月
北海茫月 2020-12-29 05:25

Sorry for a lack of example on this one, but I figure it\'s easy enough to understand.

I have a fixed background on my site, which is currently implemented like this

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 05:36

    Its hard to say without an example but you may be missing width:100% that should stop any resizing with the scroll bar.

    Another way to implement a fixed background on mobile is to have a background div with position: absolute and overflow: hidden and all your other background implementations, Then have a content div with overflow-y:scroll; and set the height of the content div using jquery or any other method you choose to get the window height with.

    Check out this JS Fiddle for an example.

提交回复
热议问题