使html文本输入字段增长,因为我键入? [英] make html text input field grow as I type?
本文介绍了使html文本输入字段增长,因为我键入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在css中设置初始文本输入大小,例如:
I can set initial text input size in css, like so:
width: 50px;
但我希望它增长,当我输入,直到它达到例如200px。
这可以直接在css,html,最好没有javascript吗?
But I would like it to grow when I type until it reaches for example 200px. Can this be done in straight css, html, preferably without javascript?
当然,post post你的js / jquery解决方案,但如果这是可行的
Do post your js/jquery solutions too of course, but if this is doable without them - that be great.
我在这里尝试:
推荐答案
以下示例仅包含CSS和 内容可编辑 :
Here is an example with only CSS and Content Editable:
CSS
span
{
border: solid 1px black;
}
div
{
max-width: 200px;
}
HTML
<div>
<span contenteditable="true">sdfsd</span>
</div>
这篇关于使html文本输入字段增长,因为我键入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文