demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

web developer guide

my books

Book cover of Pro CSS3 AnimationPro CSS3 Animation, Apress, 2013

my projects

A Sass color keyword system for designers. Replaces CSS defaults with improved hues and more memorable, relevant color names.

CSSslidy: an auto-generated #RWD image slider. 3.8K of JS, no JQuery. Drop in images, add a line of CSS. Done.

tipster.ioAutomatically provides local tipping customs and percentages for services anywhere.

The CSS3 resize property

css / properties

Estimated reading time: 2 minutes

One of the lesser-appreciated CSS3 properties, resize does exactly what it says: it allows a user to resize almost any element it is applied to. The property itself is something of a misnomer: it does not make content larger or smaller, and is perhaps more akin to a user-modifiable clip property.

resize can take four values, in addition to inherit:

none

The element cannot be resized. This is the default for the majority of elements in most browser’s UA stylesheets.

horizontal

The element may be resized by the user, but only horizontally.

vertical    

The element is restricted to vertical resizing only

both

The element may be resized both horizontally and vertically

resize does not apply to block elements in which overflow has been set to visible, nor is it supported on .

The first example of resize I’ll provide is usually terrible from a UI perspective, but useful in illustrating the property: given a div with some content, we’ll apply resize: both, producing the following:

Try resizing this div element from the bottom right corner. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

On a more practical level, browsers that currently support resize apply it to textarea by default. While this is a good idea – a user should be able to resize a textarea box to get more room for what they are typing – unrestricted resizing can spoil some page designs. In most cases, it is better to rewrite the rule to restrict resize of the textarea to one direction only:

textarea { resize: vertical; }

To this end, I have added the declaration to my suggested CSS3 reset and boilerplate code.

comments powered by Disqus

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.