Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari on iOS scrolls beyond <html> element when virtual keyboard is opened

To try it:

  1. Open this codepen in Safari 12 on iOS (device or simulator).
  2. Focus the input. The virtual keyboard should open.
  3. Now scroll all the way to the bottom of the page.
  4. You should be able to overscroll outside of the <html> element and see a white stripe the size of the Safari menu/action bar like so:

demo

  1. When you close the virtual keyboard, the stripe goes way...

Is this a bug with Safari? Any way to fix this?

like image 436
Alex Nault Avatar asked Jan 31 '26 07:01

Alex Nault


1 Answers

There is no known HTML/CSS/JS fix you can do. Try inspecting it on the safari browser by connecting your Mobile to mac Safari and debug, you can also use xcode and use mobile emulator. The HTML and BODY height is same as per the document. Apple Keyboard is adding the white space on its own which is not part of the DOM. This is valid of every website and just not affecting yours alone.

When the keyboard pops up on iOS devices, the system reserves space at the bottom of the screen for the keyboard, which can affect the layout and appearance of web pages. This behavior can lead to the perception that extra space is added at the bottom of the website. One possible reason behind this mechanism is:

Viewport Adjustment: iOS adjusts the viewport size to accommodate the keyboard. This adjustment means that the visible portion of the web page shrinks, effectively pushing content upwards to make room for the keyboard.

like image 131
Karthik Avatar answered Feb 01 '26 22:02

Karthik