V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
dblue
V2EX  ›  问与答

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

  •  
  •   dblue · 2015-10-06 19:26:45 +08:00 · 1675 次点击
    这是一个创建于 3117 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <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 条回复    2015-10-07 19:59:23 +08:00
    ljcarsenal
        1
    ljcarsenal  
       2015-10-07 11:47:14 +08:00 via Android
    监听 input focus 事件 改 padding
    dblue
        2
    dblue  
    OP
       2015-10-07 19:59:23 +08:00
    @ljcarsenal 怎么知道 padding 是多少呢?搜了貌似没有啥好办法知道虚拟键盘多高呢。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5163 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:28 · PVG 17:28 · LAX 02:28 · JFK 05:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.