html - Background image jumps when address bar hides iOS/Android/Mobile Chrome -


I am currently developing a responsive site using Twitter Bootstrap.

The site has a full screen background image in mobile / tablet / desktop. These images spin across and fade, using two divs.

This is perfect, except for an issue. Using iOS Safari, Android Browser or Chrome on Android jumps slightly in the background, when a user scrolls down the page and gives reasons to hide the address bar.

The site is here:

Go here to scroll mobile device down and down and you should see image resizing / location.

I am using the background for DV, as follows:

  # bg1 {background-color: # 3d3d3f; Background repeat: do not repeat; Background attachment: fixed; Background-condition: center center; -WebKit-Background-Size: Cover; -MOZ-BACKGROUND-SHAPE: COVER; -o-background-shape: cover; Background size: cover; Status: fixed; Width: 100%; Height: 100%; Left: 0px; Top: 0px; Z-index: -1; display none; }   

All suggestions are welcome - for some time it is doing my head!

This issue is caused by the bars of the URL / sliding out of the way and #bg1 and # BGs change the size of the 2 devices because they are 100% altitude and "fixed". Because the image of the background is set to "cover", it will adjust the image size / position as the inserted area is bigger.

Depending on the responsive nature of the site, background should be scaled. I entertain two possible solutions:

1) Set # BG1, #BG2 height up to 100 VH. In theory, this is an elegant solution. However, iOS is a VH bug () I tried to use maximum-height to prevent this issue, but it remained

2) The size of the viewport, when defined by Javascript , Then the URL is not affected by the bar, so depending on the viewport size, javascript can be used to set a constant height at # BG1 and # BG2. This is not the best solution because it is not pure CSS and there is a slight leap on page load. However, this is the only viable solution I'm considering for iOS's "VH" bugs (which have not been fixed in iOS 7).

  var bg = $ ("# bg1, # bg2"); Resize the function background () {bg.height ($ (window) .ht ()); } $ (Window). Resize (Background by resizing); ResizeBackground ();   

On the one hand, I have seen so many issues with these size URL bars in iOS and Android. I understand this purpose, but they need to think about the strange functionality and the havoc that they bring to the websites. The latest changes, you can not "hide" the URL bar on page loads on iOS or Chrome using scroll tricks.

Edit: While the above script keeps the background fully resized by resizing, the reason for this is when a significant difference between the user scrolls. This is because it keeps the background bar lower than 100% of the screen's height. If we add 60px from height, as Swiss suggests, this problem gets resolved. This means that when the URL bar is present, we will not be able to see the bottom 60 px of the background, but it prevents users from ever seeing the gap.

  Change the size of the background Background () {bg .it ($ (window). Height () + 60); }    

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -