0

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)?

Jude Fisher
  • 11,138
  • 7
  • 48
  • 91
Tommy
  • 573
  • 3
  • 8
  • 25

2 Answers2

3

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

Community
  • 1
  • 1
markle976
  • 957
  • 1
  • 6
  • 10
1

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

Community
  • 1
  • 1
Shail
  • 3,639
  • 1
  • 18
  • 29