如何在HTML中定义输入文本框的大小? [英] How can the size of an input text box be defined in HTML?
本文介绍了如何在HTML中定义输入文本框的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< input type =textid =textname = text_name/>
有哪些选项可以定义框的大小?
这怎么能在CSS中实现?
解决方案
你可以设置它的宽度:
< input type =textid =textname =text_name style =width:300px; />
甚至可以更好地定义一个类:
< input type =textid =textname =text_nameclass =mytext/>
并在一个单独的CSS文件中应用必要的样式:
.mytext {
width:300px;
$ / code>
如果您想限制用户可以输入的字符数您可以使用 maxlength
属性:
< input type = textid =textname =text_nameclass =mytextmaxlength =25/>
Here is an HTML input text box:
<input type="text" id="text" name="text_name" />
What are the options to define the size of the box?
How can this be implemented in CSS?
解决方案
You could set its width
:
<input type="text" id="text" name="text_name" style="width: 300px;" />
or even better define a class:
<input type="text" id="text" name="text_name" class="mytext" />
and in a separate CSS file apply the necessary styling:
.mytext {
width: 300px;
}
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" />
这篇关于如何在HTML中定义输入文本框的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文