+ 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/
14 ответов
+ 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
+ 3
div{
min-height:30px;
width:100px;
display:inline-block;
background-color:orange;
}
+ 3
Abhay I didn't understand how this will work
+ 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
+ 3
Abhay But I want a input field cause user will type in it
+ 3
You can do the same with input field ,show your code so I can understand better what you want to do
+ 3
Yash Arora🇮🇳 so you want that input field to grow vertically right?
+ 3
Abhay Yeah when the input grows it should not be scrollable instead the height should increase
+ 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
+ 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,
+ 3
Abhay but if you have some another way pls tell me
+ 3
Abhay no worries
+ 3
Abhay thank you really I was getting sad cause of this idk why but thanks