by tannhaeuser · 3y ago · 0 comments
> My favorite trick of doing this before was using CSS grid. You’d take the text inside the textarea and propagate it to a hidden psuedo element overlaid exactly on top. That stack technique is a classic:
.grid {
display: grid;
grid: stack;
> *, &::after {
grid-area: stack;
}
}
So much for the hope to start clean with flex, grid, and co.(Btw, there's a typo: psuedo -> pseudo)
<textarea oninput="this.style.height = 0; this.style.height = this.scrollHeight + 'px'"></textarea>
(Yes this forces an extra reflow but it likely won't matter)It's also worth learning because tools like Figma or editors like Microsoft Publisher, Word/Docs, etc all have their design tools heavily influenced by CSS. Using those tools will make a lot more sense if you know CSS