dblue
V2EX  ›  问与答

[css] 在 iPhone 的浏览器里, fixed header 如何能够在激活底部输入框,出现了虚拟键盘导致页面高度不够,维持 header 的 fixed 相对屏幕的位置不变?

  •  
  •   dblue · Oct 6, 2015 · 2556 views
    This topic created in 3897 days ago, the information mentioned may be changed or developed.
    <body>
        <div id="fixed top0">
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        </div>
        <div class="absolute bottom0 height45px">
          <input type="text">
        </div>
    </body>
    

    如果点击 text ,虚拟键盘在 ios 下面拉出来,会把整个页面都挤上去。。如何才能这时依然贴着窗口顶部呢?搜了一下貌似让他跟着挤上去才是一般地做法。。(但不符合这个应用的交互要求)

    在 android 没有这个问题……

    2 replies    2015-10-07 19:59:23 +08:00
    ljcarsenal
        1
    ljcarsenal  
       Oct 7, 2015 via Android
    监听 input focus 事件 改 padding
    dblue
        2
    dblue  
    OP
       Oct 7, 2015
    @ljcarsenal 怎么知道 padding 是多少呢?搜了貌似没有啥好办法知道虚拟键盘多高呢。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1198 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:45 · PVG 07:45 · LAX 16:45 · JFK 19:45
    ♥ Do have faith in what you're doing.