7

How to enable automatic scroll to focus input when keyboard are open ? I create a simple demo where are 2 inputs:

<div style="height:300px;"></div>
<form action="/">
   <input type="text" />
   <br/>
   <input type="text" /> 
   <button>ok</button>
</form>
<div style="height:300px;"></div>

When I click on input in the bottom on the page, keyboard open and hide input. example

I open from my phone w3s site ant on them when I click on input when it of the bottom of the page browser automatically scrolled it into view. w3s site

What I need to do that automatic scroll into view of focus input will start work on my demo ?

Kholiavko
  • 334
  • 3
  • 11
  • You should find this to be helpful (http://stackoverflow.com/a/1586366/3011082). Tell me what happens :) – www139 Dec 27 '16 at 18:51
  • I know this way, but I think this is default browser feature now, because on any site it wokrs properly, but not on my :) – Kholiavko Dec 27 '16 at 19:01

1 Answers1

0

I sloved the problem. In my case it was because the body height was smaller then content height. And on codepen I think it was because it render via iframe.

Kholiavko
  • 334
  • 3
  • 11