>我有类型为"text"的标签,限制为 2,000 个字符。 我想换行,但是" 换行:断词;"不起作用,因为它不是div。
这是 CSS:
background: #ffffff;
-moz-box-sizing: border-box;
border: 1px solid #CBD5DD;
border-radius: 2px;
height: 70px;
max-width: 450px;
word-wrap: break-word;
margin: 0;
min-height: 33px;
overflow: visible;
position: relative;
width: 450px;
padding-left:5px;
vertical-align:top;
box-sizing: border-box;
有什么建议吗? 谢谢
你不能在input[type="text"]
中更改行,你必须使用Textarea
或任何元素与contenteditable="true"
例如
[contenteditable="true"] {
background: #ffffff;
-moz-box-sizing: border-box;
border: 1px solid #CBD5DD;
border-radius: 2px;
max-height: 70px;
max-width: 450px;
word-wrap: break-word;
margin: 0;
min-height: 33px;
overflow: auto;
position: relative;
width: 450px;
padding-left: 5px;
vertical-align: top;
box-sizing: border-box;
}
<div contenteditable="true"></div>
input[type="text"]
中不能有换行符,因为它不支持多行,请改用textarea
。