如何将所有 td space 与文本区域一起使用?

How can I use all td space with a textarea?

我希望我的 textarea 使用所有 height space 和 css 配置,但我不能。你能帮我么?谢谢。

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        td{
            border: solid black 1px;
        }
        textarea{
            height: 100%;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <td>
                <textarea class="textarea1"></textarea>
            </td>
            <td>
                a<br/>
                a<br/>
                a<br/>
                a<br/>
                a<br/>
            </td>
        </tr>
    </table>
</body>
</html>

td还需要height: 100%。我将它应用于所有这些,但您可能只想将其限制为具有 textarea 的那个,具体取决于您如何实现它。还制作了 textarea display: block,因为这将删除底部的一点点白色 space。您也可以使用 vertical-align: top 而不是 display: block

<!DOCTYPE html>
<html>

<head>
  <title></title>
  <style type="text/css">
    table,tr,td{
      height: 100%;
    }
    td { border: solid black 1px; }
    textarea{
      height: 100%;
      display: block;
    }
  </style>
</head>

<body>
  <table>
    <tr>
      <td>
        <textarea class="textarea1"></textarea>
      </td>
      <td>
        a<br/> a
        <br/> a
        <br/> a
        <br/> a
        <br/>
      </td>
    </tr>
  </table>
</body>

</html>

试试这个

td{
        border: solid black 1px;
        height: 100%;
        padding:0px;
    }
    textarea{
        height: 100%;
        display: block;
    }
<table>
  <tr>
    <td><textarea></textarea></td>
  </tr>
</table>