Tommy
Tommy

Reputation: 583

Horizontally-expanding HTML input field

I have an input field:

<input type="text" id="TextField" />

and set it to resize:

#TextField {
   resize: horizontal;
}

But it does not resize.

How can I have a text field resize horizontally (not vertically) when the text nears the end (right) of the text field? Or, are there any built-in ways for this to work (maybe using something in CSS)?

Upvotes: 0

Views: 4144

Answers (2)

Shail
Shail

Reputation: 3649

BTW there's a plugin which can help you achieve what you are looking for Resize INput box

Upvotes: 1

markle976
markle976

Reputation: 967

You will need to calculate the width of the box based on the width of the text. Here is a simalar question that might help. Calculate text width with JavaScript

Upvotes: 3

Related Questions