With the introduction of CSS3, one of the new properties available is resize. With it we are able to make an element resizable vertically, horizontally or both.
We have to take note that the property is available only for Firefox, Chrome and Safari. For those browsers, some elements like the textarea are considered resizable by default (and you may have already noticed that).
Let's see how to use it.
SyntaxThe syntax is very simple. The property accepts 4 values:
When we apply the property to an element, we need to create a rule like:
The property will apply to a div with class="ResDiv":
Want to see it in action? Here you are:
<div class="ResDiv">This is a vertically resizable div</div>
This is a vertically resizable div
Nothing too much complicated.
Control the sizeWhen an element is resizable by the user, we might want to restrict the available sizes. In order to take control of the maximum or minimum element size, we can always use CSS and specifically the following properties:
Those properties will help us in controlling what the user can do with our resizable element. In the above example I set the max and the min heights.