Interaction

resize

resize adds a handle to the corner of an element so people can drag to change its size. You can limit it to one direction.

Syntax

none | both | horizontal | vertical | block | inline

Preview

NoteThe quick brown fox jumps over the lazy dog. 素早い茶色の狐がのろまな犬を飛び越える。
Presets
Drag the bottom-right corner to resize

Code

.box > :nth-child(2) {
  overflow: auto;
  resize: both;
}

Controls

resizeboth
resize
NoteThe quick brown fox jumps over the lazy dog. 素早い茶色の狐がのろまな犬を飛び越える。

About

Values

  • none (initial): no handle.
  • both: both the width and the height can change.
  • horizontal / vertical: only the width / only the height.
  • block / inline: only the direction lines stack in / only the direction text runs in. In horizontal writing they match vertical / horizontal; in vertical writing they swap.

The preview sets it on the note (the second child). Drag the bottom-right corner of the note to resize it.

Only for elements that scroll

resize only works on elements whose overflow is auto, scroll or hidden. With the initial visible, or with clip, no handle appears, so the preview also writes overflow: auto as a helper declaration. (Some browsers also apply it to images and iframes regardless of overflow.)

Watch out

  • Browsers style textarea so it can already be resized in both directions. Write resize: vertical or resize: none when it shouldn’t break your layout.
  • While dragging, the browser writes width and height in px into the element’s style attribute. Use max-width or min-height to keep the size within bounds.
  • Some browsers don’t let you drag the handle with touch.

Comments