html - Resizable TextArea upto a certain size -


i creating text area field in angular4/bootstrap3 run on ie11.

the text area pre-filled text

<textarea [value]="mydata" class="form-control" rows="5"></textarea> 

this works way 1 expect to. 5 rows shown , if text exceeds can fitted 5 rows, scrollbar displayed. if text less empty space displayed in text area.

what trying achieve little different default behavior. textarea resizable size should not exceed number of rows. lets max size set 5 rows. so, if text displayed can fitted in 1 row, text area shows 1 row. if can fitted in 4 rows expands 4 rows. if can fitted in 10 rows, expands 5 rows , shows scrollbar remaining text.

is such kind of behaviour possible? have used rows example, if can achieved height property or else, fine well.

you can achieve little css, , using max-height property:

textarea {     overflow-y:scroll     max-height:100px; /* change height see fit */ } 

by not setting default height, text area high enough content less max-height, , when hits it, it'll start scrolling.

also, remove rows attribute textarea.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -