V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
LLaMA
V2EX  ›  程序员

为什么我写的表单页面输入框高度一直没办法占满页面?

  •  
  •   LLaMA · 2023-03-17 21:22:20 +08:00 · 590 次点击
    这是一个创建于 404 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>表单页面</title>
        <style>
          body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            background-color: #F2F2F2;
          }
    
          #form-container {
            margin: 20px auto;
            height: calc(100vh - 40px);
            padding: 20px;
            background-color: #FFFFFF;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
            border-radius: 10px;
            display: flex;
            flex-direction: column;
            justify-content: center;
          }
    
          #form-container textarea {
            flex: 1;
            width: 100%;
            height: 100%;
            padding: 10px;
            font-size: 16px;
            border-radius: 5px;
            border: none;
            background-color: #F2F2F2;
            resize: none;
          }
    
          #form-container input[type="submit"] {
            margin-top: 20px;
            padding: 10px;
            font-size: 16px;
            border-radius: 5px;
            border: none;
            background-color: #007AFF;
            color: #FFFFFF;
          }
        </style>
      </head>
      <body onload="document.getElementById('input').focus();">
        <div id="form-container">
          <form>
            <textarea placeholder="请输入内容" id="input"></textarea>
            <input type="submit" value="提交">
          </form>
        </div>
      </body>
    </html>
    

    想要的效果是输入框的高度能自适应除去移动端虚拟键盘(如果弹出)+提交按钮的高度

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1191 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:19 · PVG 02:19 · LAX 11:19 · JFK 14:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.