如何更改输入文本框的大小?
问题描述:
如何更改类型文本输入的框大小
How can i change the box size of the input of type text
<input type="text" id="text" name="text_name" />
我可以通过编辑css吗?
Can i do that with editing css ?
答
您可以设置 width
:
<input type="text" id="text" name="text_name" style="width: 300px;" />
或更好地定义一个类:
<input type="text" id="text" name="text_name" class="mytext" />
并在单独的CSS文件中应用必要的样式:
and in a separate CSS file apply the necessary styling:
.mytext {
width: 300px;
}
如果要限制用户可以键入的字符数textbox你可以使用 maxlength
属性:
If you want to limit the number of characters that the user can type into this textbox you could use the maxlength
attribute:
<input type="text" id="text" name="text_name" class="mytext" maxlength="25" />