CSS Box Resize Generator
WM-110Set which directions a box can be resized in, its starting size and optional minimum and maximum sizes, then drag the corner of the preview to try it before you copy the CSS.
Runs in your browser. Nothing is uploaded.
Box
Preview and CSS
| width | 240px |
|---|---|
| height | 140px |
| overflow | auto |
| resize | both |
CSS
.box {
width: 240px;
height: 140px;
overflow: auto;
resize: both;
} How to use it
- Choose the direction: both, horizontal, vertical or none.
- Pick an overflow value. The resize handle only appears when it is not visible.
- Set the starting width and height, and any minimum or maximum size.
- Drag the bottom-right corner of the preview to test, then press Copy.
How the resize property works
The resize property adds a drag handle to the bottom-right corner of a box. It takes both, horizontal, vertical or none, and it only has an effect when overflow is set to something other than visible. That is why this tool always writes an overflow line. Most browsers already make a textarea resizable, and this property lets you do the same for any block box or turn it off.
Limiting the size
Without limits a visitor can drag the box to any size. Min width, min height, max width and max height are written only when you set them above 0, and they stop the drag at those sizes. If a max is smaller than its min the tool reports an error. Dragging the preview only changes it until your next edit, and sizes are in pixels.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Max width must not be smaller than min width. | The maximum width you entered is below the minimum width. | Raise the maximum or lower the minimum, or set the maximum to 0 for no limit. |
Questions people ask
Why is there no resize handle on my element?
The resize property needs overflow set to auto, hidden or scroll. With the default overflow of visible the handle does not appear, so always pair resize with one of those values.
Can I make a div resizable?
Yes. Give the div a width, a height, an overflow other than visible and resize: both, or the direction you want. The CSS here is a complete rule you can paste onto any block-level element.
How do I stop a textarea being resized?
Set resize: none on it. Choose None here and copy the rule, then change the selector from .box to textarea or the class your textarea uses.
Does resize work on touch screens?
Support varies by browser and device, and dragging a small corner handle can be hard on a phone. Do not rely on it as the only way to change a layout.
Which overflow value should I choose?
Auto shows scrollbars only when content does not fit, hidden clips overflowing content, and scroll always shows scrollbars. Auto suits most boxes, and hidden suits boxes where you do not want scrolling.
About this tool
Writes a box with a width, a height, an overflow value and the resize property. The resize property only works when overflow is something other than visible, which is why overflow is always written. Min and max sizes are written only when they are not 0 and limit how far the visitor can drag. Dragging the preview changes it only until the next edit. Sizes are in pixels, and the preview box uses exactly the CSS shown.