babiro babiro - 4 months ago 32
CSS Question

Maximum height of textarea to 300px (Javascript)

I can't make a maximum height limit to 300px of textarea which height varies.


Thanks in advance.


It's simply a matter of checking the height prior to resizing. If you would like to eliminate scrollbar flicker consider setting overlflow-y to hidden until 300:

function resize () {

    var height = text.scrollHeight <= 300 ? text.scrollHeight : 300; = height+'px';


fiddle -