有没有办法使用CSS或HTML更改表单中的字段大小?

时间:2015-02-02 07:55:28

标签: html css

表单框/字段通常非常大。我想知道是否有办法让它们在CSS或HTML中更小,因为没有其他的尺寸选项。谢谢!

3 个答案:

答案 0 :(得分:3)

CSS用于调整整个表单的高度,宽度和对齐方式。

form {
      width:550px;
      height:450px;
      margin:auto;
      position:relative;
}

用于调整输入字段高度和宽度的CSS。

input {
       width:375px;
       height: 25px;
      }

还使用Html:

 <form action="demo_form.asp">
      Email: <input type="text" name="email" size="35"><br>
      PIN: <input type="text" name="pin" maxlength="4" size="4"><br>
      <input type="submit" value="Submit">
</form> 

请参阅:http://www.w3schools.com/tags/att_input_size.asp

答案 1 :(得分:1)

是的。使用HTML。

阅读本文:

http://www.w3schools.com/tags/att_input_size.asp

所以像这样使用它:

<input type="text" name="email" size="2">

答案 2 :(得分:1)

可以使用widthheight属性在CSS中设置字段的大小。字体大小设置也可能间接影响尺寸。此外,填充设置可能会产生影响。

对于input type=text,也可以使用size属性设置宽度,但只有在使用等宽字体时,才能提供一致的(跨浏览器)结果。例如:

&#13;
&#13;
<input size="8" style="font-family: Consolas, monospace" value="12345678">
&#13;
&#13;
&#13;

对于textarea元素,也可以使用rowscols属性。