resize

resizeCSS のプロパティで、要素の寸法を変更できるかどうか、もしそうなら、どの方向に変更できるかを設定します。

試してみましょう

resize は以下のものには適用されません。

  • インライン要素
  • overflow プロパティが visible であるブロック要素

構文

css
/* キーワード値 */
resize: none;
resize: both;
resize: horizontal;
resize: vertical;
resize: block;
resize: inline;

/* グローバル値 */
resize: inherit;
resize: initial;
resize: revert;
resize: revert-layer;
resize: unset;

resize プロパティは以下に挙げるキーワードから単一の値を指定します。

none

ユーザーが要素の寸法を制御する方法を提供しません。

both

要素はユーザーが寸法を変更できる仕組みを、垂直方向と水平方向の両方について表示します。

horizontal

要素はユーザーが寸法を変更できる仕組みを、水平方向について表示します。

vertical

要素はユーザーが寸法を変更できる仕組みを、垂直方向について表示します。

block Experimental

要素はユーザーが寸法を変更できる仕組みを、ブロック方向について表示します (writing-modedirection の値によって、水平方向または垂直方向のどちらかになります)。

inline Experimental

要素はユーザーが寸法を変更できる仕組みを、インライン方向について表示します (writing-modedirection の値によって、水平方向または垂直方向のどちらかになります)。

公式定義

初期値none
適用対象overflowvisible 以外である要素、任意で画像、動画、iframe を表す置換要素
継承なし
計算値指定通り
アニメーションの種類離散値

形式文法

resize = 
none |
both |
horizontal |
vertical |
block |
inline

テキストエリアの寸法の変更を無効化

多くのブラウザーでは、 <textarea> 要素は既定で寸法が変更できます。 resize プロパティでこの動作を上書きすることができます。

HTML

html
<textarea>Type some text here.</textarea>

CSS

css
textarea {
  resize: none; /* Disables resizability */
}

結果

任意の要素に対する resize の使用

resize プロパティを使用して、任意の要素の寸法を変更可能にすることができます。以下の例では、寸法が変更可能な <div> の中に、寸法が変更可能な段落 (<p> 要素) を配置しています。

HTML

html
<div class="resizable">
  <p class="resizable">
    This paragraph is resizable in all directions, because the CSS `resize`
    property is set to `both` on this element.
  </p>
</div>

CSS

css
.resizable {
  resize: both;
  overflow: scroll;
  border: 1px solid black;
}

div {
  height: 300px;
  width: 300px;
}

p {
  height: 200px;
  width: 200px;
}

結果

仕様書

Specification
CSS Basic User Interface Module Level 4
# resize

ブラウザーの互換性

BCD tables only load in the browser

関連情報