javascript - 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>
解决方案
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>
推荐阅读
- mysql - 如何在 SQL 的 WHERE 子句中使用 IN 运算符和 AND 运算符...?
- python - 为什么我的代码没有产生预期的结果?
- unit-testing - Vue.js - Vuetify - 很难测试菜单组件
- moodle - 如何通过moodle API显示和返回moodle课程内容?
- php - Laravel 自定义错误验证 JSON 响应对象到数组
- javascript - Array.forEach 中的 Node.Js 异步请求在写入 json 文件之前未完成
- iphone - Swift 4 中按国家/地区的 Google Places Search AutoComplete 过滤结果
- excel - 使用宏使 Excel 数据输入更快?
- c# - 如何在 C# 中使用 Selenium Webdriver 处理 Chrome 浏览器的 cookie?
- google-cloud-platform - 使用 apache flink 从 google pub/sub 流式传输