AutoGrow Textareas with CSS

Date:

Share post:

As the demands of the web change and developers experiment with different user experiences, the need for more native language improvements expands. Our presentation layer, CSS, has done incredibly well in improving capabilities, even if sometimes too slow. The need for native support for automatically expanding textarea elements has been long known…and it’s finally here!

To allow textarea elements to grow vertically and horizontally, add the field-sizing property with a value of content:

textarea {
  field-sizing: content; // default is `fixed`
}

The default value for field-sizing is fixed, signaling current behavior. The new behavior, content, will expand as much as possible. To constrain the size a textarea can grow, use traditional width/max-width and height/max-height properties.

Request Metrics real user monitoring
Request Metrics real user monitoring
Request Metrics real user monitoring
  • 7 Essential JavaScript Functions

    7 Essential JavaScript Functions

    I remember the early days of JavaScript where you needed a simple function for just about everything because the browser vendors implemented features differently, and not just edge features, basic features, like addEventListener and attachEvent.  Times have changed but there are still a few functions each developer should…

  • fetch API

    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn’t really made for what we’ve been using it for.  We’ve done well to create elegant APIs around XHR but we know we can do better.  Our effort to…

  • dwProgressBar v2:  Stepping and Events

    dwProgressBar v2: Stepping and Events

    dwProgressBar was a huge hit when it debuted. For those of you who didn’t catch my first post, dwProgressBar is a MooTools 1.2-based progress bar which allows for as much flexibility as possible. Every piece of dwProgressBar can be controlled by CSS…

  • MooTools Zebra Tables Plugin

    MooTools Zebra Tables Plugin

    Tabular data can oftentimes be boring, but it doesn’t need to look that way! With a small MooTools class, I can make tabular data extremely easy to read by implementing “zebra” tables — tables with alternating row background colors. The CSS The above CSS is extremely basic.


Source link
spot_img

Related articles

September Patch Tuesday handles 81 CVEs – Sophos News

.Microsoft on Tuesday announced 81 patches affecting 15 product families. Nine of the addressed issues are considered by...

Follow This Advice Before Switching to a New iPhone 17

Are you considering getting one of the new iPhone 17 models? While it’s always tempting to unbox a...

Just Look How Bloody Gross Universal’s ‘Terrifier’ Haunted House Is

Damien Leone, the writer and director of the Terrifier film...

Turtle Beach Unveils New Range Of Officially Licensed Switch 2 Accessories – Controllers, Cases And More

If you're still on the hunt for certain Switch 2 accessories and are looking for alternatives to Nintendo's...