I cannot find a clear answer to this, and sorry if there is one that I missed.
I want my text input widths to automatically adjust to the size of the content inside them. First with placeholder text than with actual text that someone enters.
As an example, I created below. Currently, the boxes are much larger than my placeholder text, causing a huge amount of spaces, and this is obviously the same when I type in something.
I tried the auto width, some jQuery, and the twine and bubble rubber that I found on the Internet. But so far nothing has happened. Any thoughts? Thanks!
HTML:
<span><p>Hello, my name is </p></span> <span><input type="text" id="input" class="form" placeholder="name"></span> <span><p>. I am </p></span> <span><input type="text" id="input" class="form" placeholder="age"></span> <span><p> years old.</p></span>
CSS
.form { border: 0; text-align: center; outline: none; } span { display: inline-block; } p { font-family: arial; }
Fiddle
javascript jquery html input forms
ObbyOss
source share