美文网首页
聊天界面布局

聊天界面布局

作者: 反者道之动001 | 来源:发表于2019-07-10 12:39 被阅读0次

总的有三部分

  • 头部
  • 聊天内容
  • 输入框

布局如下

    <div style="position: fixed; bottom: 0px;"></div>
        <div  style="position: relative; top: 0px; width: 100%; background: red">群聊1</div>
        <div style="height: 450px" id="h">聊天内容</div>
        <input type="text" onfocus="f()" onblur="b()">
    </div>
  <script>
    window.f = () => {
      h.scrollIntoView()
      h.style.height = '200px'
    }
    window.b = () => {
      h.style.height = '450px'
    }
  </script>

之所以加,scrollIntoView, 因为软键盘把内容被顶上去了(白屏),scrollIntoView把它拉回来

但是这时候会有一个明显的滑动过程,特别是头部。

如图

相关文章

网友评论

      本文标题:聊天界面布局

      本文链接:https://www.haomeiwen.com/subject/oyockctx.html