Html 你能让 <input type="text"> 元素的尺寸小于 1 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4019592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can you make a <input type="text"> element have a size shorter than 1?
提问by chromedude
I have an <input>
that I want to be smaller than size="1"
but I do not know how to make it smaller. Is it possible to do this?
我有一个<input>
我想比它小,size="1"
但我不知道如何使它更小。是否有可能做到这一点?
I tried using fractions and decimals but neither worked.
我尝试使用分数和小数,但都没有奏效。
回答by Pekka
You can assign it a pixel width instead:
您可以改为为它分配一个像素宽度:
<input type="text" style="width: 4px">
回答by CanSpice
For type="text"
, no. At least, not using the size
attribute:
对于type="text"
,没有。至少,不使用size
属性:
The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters.
宽度以像素为单位给出,除非类型属性具有值“文本”或“密码”。在这种情况下,它的值是指(整数)字符数。