CSS Resize Generator
Make a box or textarea resizable by the user, set limits, drag the live preview, and copy the CSS.
Make a box or textarea resizable by the user, set limits, drag the live preview, and copy the CSS.
resize lets visitors drag the bottom-right corner of an element to change its size. It takes both, horizontal, vertical or none, plus the logical values block and inline, which follow the writing direction. Pick a value, set limits, and drag the preview to feel the result before copying the CSS.
One rule trips people up: resize only works when overflow is something other than visible. That is why the generated CSS adds overflow: auto to boxes. Textareas are already scrollable, so they do not need it.
| Goal | CSS |
|---|---|
| Stop users breaking a form layout by widening a textarea | textarea { resize: vertical; } |
| Disable resizing completely | textarea { resize: none; } (give it a sensible height, or auto-grow it with field-sizing: content in browsers that support it) |
| Resizable side panel | resize: horizontal; overflow: auto; min-width: 200px; max-width: 50vw; |
| Resizable code or preview pane | resize: both; overflow: auto; with min and max sizes |
min-width, max-width, min-height and max-height stop users from shrinking an element to nothing or stretching it over the rest of the page. Without a max-width, a horizontally resizable element can push past its container and cause horizontal scrolling on mobile.
The resize handle can only be used with a pointer, so do not make resizing the only way to see content: keep content scrollable inside the element. Browsers do not show the handle on most touch devices.
Its overflow is visible (the default) or it is an inline element. Add overflow: auto and make sure it is a block or inline-block element.
Yes, with a ResizeObserver in JavaScript, which is what the size readout under the preview uses.