首页 > 解决方案 > html css中输入标签的下一行可以吗?

问题描述

我有一个输入标签,当我输入输入时,在给定宽度后,文本被溢出隐藏。我真正需要的是当我输入输入时,文本转到下一行,这可能吗?只输入不是文本区域。

    input {
        height: auto;
    
    }
<!DOCTYPE html>
<html>
<body>

<h1>The input element</h1>

<form action="/action_page.php">
  <input type="text"  id="comment" name="comment" /><br/>
  <input type="submit" value="Submit">
</form>

<p>Click the "Submit" button and the form-data will be sent to a page on the 
server called "action_page.php".</p>

</body>

</html>

标签: javascripthtmlcssreactjsinput

解决方案


autosize(document.getElementById("comment"));
#comment{
    resize: none;
    height: 16px;
}
<!DOCTYPE html>
<html>
<body>

<h1>The input element</h1>

<form action="/action_page.php">
  <textarea id="comment" name="comment"></textarea><br/>
  <input type="submit" value="Submit">
</form>

<p>Click the "Submit" button and the form-data will be sent to a page on the 
server called "action_page.php".</p>

</body>
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
</html>


推荐阅读