Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在HTML中定义输入文本框的大小?_Html_Css_Input - Fatal编程技术网

如何在HTML中定义输入文本框的大小?

如何在HTML中定义输入文本框的大小?,html,css,input,Html,Css,Input,这是一个HTML输入文本框: <input type="text" id="text" name="text_name" /> 定义框大小的选项有哪些 如何在CSS中实现这一点?您可以设置其宽度: <input type="text" id="text" name="text_name" style="width: 300px;" /> 如果要限制用户可以在此文本框中键入的字符数,可以使用maxlength属性: <input type="text" id=

这是一个HTML输入文本框:

<input type="text" id="text" name="text_name" />

定义框大小的选项有哪些


如何在CSS中实现这一点?

您可以设置其
宽度:

<input type="text" id="text" name="text_name" style="width: 300px;" />
如果要限制用户可以在此文本框中键入的字符数,可以使用
maxlength
属性:

<input type="text" id="text" name="text_name" class="mytext" maxlength="25" />

属性
size
也起作用


试试这个

<input type="text" style="font-size:18pt;height:420px;width:200px;">

可以通过内嵌样式设置宽度(以像素为单位):


还可以使用可见字符长度设置宽度:



“大小”指定元素输入的可见宽度(以字符为单位)

您还可以使用css中的高度和宽度

<input type="text" name="name" style="height:100px; width:300px;">


另外:您可以根据“em”(而不是“px”)更改宽度,然后大小与文本框的字体大小成比例。在某些情况下,仅设置
最大宽度就足够了。您的答案没有添加任何新内容,您应该在cssWell中指定单位(px、pt、%v等)-字体大小(style=“font size:18pt”)就是我要找的那个,这也增加了盒子的尺寸。虽然OP没有明确要求,但它也增加了价值。因此,非常感谢。然而,文本似乎垂直居中。我能以任何方式阻止吗?@AaronJohnSabu抱歉耽搁了。。尝试增加宽度大小。。希望您已经找到答案。这个大小属性通常以什么单位度量?如果输入类型为“text”或“password”,那么大小指的是字符数。您可以通过这种方式控制输入的宽度。看见
<input type="text" style="font-size:18pt;height:420px;width:200px;">
 <input type="text" id="txtbox">
 #txtbox
    {
     font-size:18pt;
     height:420px;
     width:200px;
    }
<input size="45" type="text" name="name">
<input type="text" name="name" style="height:100px; width:300px;">