+ 3

I want to make a input field which can resize itself[solved]

When I type and the text gets to the edge of input field it should automatically resize and height should be increased like in this article of css-tricks it is given in other ideas section but I can't understand the code😔 https://css-tricks.com/auto-growing-inputs-textareas/

21st Oct 2020, 8:32 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
14 Respostas
+ 3
Yash Arora🇮🇳 instead of figuring out how to apply that functionality to built-in input method you can use a custom one by setting a container(div) to be editable using content editable attribute and applying any other functionality you want using js , https://code.sololearn.com/WjT7W0r7U73l/?ref=app
21st Oct 2020, 10:56 PM
Abhay
Abhay - avatar
+ 3
div{ min-height:30px; width:100px; display:inline-block; background-color:orange; }
21st Oct 2020, 10:05 PM
Abhay
Abhay - avatar
+ 3
Abhay I didn't understand how this will work
21st Oct 2020, 10:06 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Yash Arora🇮🇳 Elements with display set to inline-block automatically resizes themselves according to content in the x direction, Now the above code has set a fixed width of 100px and min-height of 30px ,anything set to fixed won't grow but using min tells browser to expand it's size if the content inside it grows,and actually you can remove display: inline-block and it will still work fine
21st Oct 2020, 10:13 PM
Abhay
Abhay - avatar
+ 3
Abhay But I want a input field cause user will type in it
21st Oct 2020, 10:14 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
You can do the same with input field ,show your code so I can understand better what you want to do
21st Oct 2020, 10:15 PM
Abhay
Abhay - avatar
21st Oct 2020, 10:16 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Yash Arora🇮🇳 so you want that input field to grow vertically right?
21st Oct 2020, 10:17 PM
Abhay
Abhay - avatar
+ 3
Abhay Yeah when the input grows it should not be scrollable instead the height should increase
21st Oct 2020, 10:19 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Umm sorry Abhay but I saw that the code snippet given on page I mentioned had a button to see the css file and now I have copied the code and will get in detail https://code.sololearn.com/Weu04I3V7Gdd/?ref=app Sorry if I bothered you
21st Oct 2020, 10:27 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Yash Arora🇮🇳 sorry i can't help!!, this is much harder than I thought it to be ,the actual input element consists of some other element that expands horizontally and I know nothing about how would you go on altering this behaviour,
21st Oct 2020, 10:34 PM
Abhay
Abhay - avatar
+ 3
Abhay but if you have some another way pls tell me
21st Oct 2020, 10:34 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Abhay no worries
21st Oct 2020, 10:34 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
+ 3
Abhay thank you really I was getting sad cause of this idk why but thanks
21st Oct 2020, 10:58 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar