本文介绍了如何匹配文本输入框的大小和最大长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你如何匹配文本输入框的大小和最大长度?这是非常烦人的,maxlength和大小属性不排队,并依赖于字体的使用。
示例输入: < input type =textsize =4maxlength =4/>
有什么建议?
解决方案
< input type =textmaxlength =4 value =1234/>
input {width:30px;}
你也可以想出一些功能来根据字符,字体大小和语言来设置它的大小。例如:
$ b 示例:
How do you match up the size and maxlength of a text input box? It is very annoying that the maxlength and size attributes don't line up and are dependent on the font use.
Example input:<input type="text" size="4" maxlength="4" />
Any suggestions?
解决方案
I don't think it will match up and it will very depending on the browser. Best bet is to use CSS to set the width of the input.
<input type="text" maxlength="4" value="1234" />
input {width:30px;}
You could also come up with some sort of function to size it based off of character, font size, and language. Something like this for example..
Example:
http://jsfiddle.net/krishollenbeck/ohpy5L95/3/
这篇关于如何匹配文本输入框的大小和最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!