Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by Rizumu Ayaka for How to auto-size a textarea in height?

It is recommended to add a step to calculate the thickness, which can correctly handle the border width on the input box and avoid unexpected scrolling.

textarea.oninput = function () {  textarea.style.height = 'auto'  const thickness = textarea.offsetHeight - textarea.clientHeight  textarea.style.height = `${textarea.scrollHeight + thickness}px`}

Viewing all articles
Browse latest Browse all 4

Trending Articles