Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed navbar separates from top of browser on Chrome for iPhone

I have a website with a bootstrap fixed-to-top navigation bar (example here), and noticed that, using Chrome on an iPhone, the navbar separates from the top of the screen by just a few pixels when scrolling quickly. This is shown in the following screenshot, from the bootstrap navbar example page:

Fixed navbar separation

This only happens on Chrome on an iPhone, and not on an iPad or any Mac/PC I've tested. It also happens on every website with a fixed navbar that I could find. The only thing I can think of is to extend the background color of the navbar up above the top of the browser so that, when the navbar is eventually pulled down, it doesn't fully separate from the screen. However, that still leaves the content of the navbar pulled down, and certainly seems like a dirty fix.

Has anyone else run into this issue, and is there any sort of known fix available?

like image 350
Mike Lewis Avatar asked Feb 02 '16 10:02

Mike Lewis


2 Answers

I used a tricky way to cover this gap,
I set padding-top:100px to the nav, and then margin-top:-100px,
so when it happened again, the gap would be filled by the padding-top.

It works fine so far, and hope this can help you, too.

like image 128
蔡佳峰 Avatar answered Nov 19 '22 15:11

蔡佳峰


OK, so I've had the same problem, of having a space before the entire contents of <body> in chrome, the solution found in the end? I had a space ' ' symbol at the start of the doc, before the <!DOCTYPE html> tag, removing it fixed everything.

Could not believe it.

like image 44
Shachar Silbert Avatar answered Nov 19 '22 15:11

Shachar Silbert