isolation

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

CSSisolation プロパティは、要素が新しい重ね合わせコンテキストを生成する必要があるかどうかを定義します。

試してみましょう

このプロパティは mix-blend-mode との組み合わせで使用すると特に有用です。

構文

css
/* キーワード値 */
isolation: auto;
isolation: isolate;

/* グローバル値 */
isolation: inherit;
isolation: initial;
isolation: revert;
isolation: unset;

isolation プロパティは、以下の一覧にあるキーワード値のうちの一つで指定します。

auto

何れかのプロパティが必要な要素に適用された場合にのみ、新しい重ね合わせコンテキストが作成されます。

isolate

新しい重ね合わせコンテキストが必ず作成されます。

公式定義

初期値auto
適用対象すべての要素。 SVG では、コンテナー要素、グラフィック要素、グラフィック参照要素に適用されます。
継承なし
計算値指定通り
アニメーションの種類アニメーション不可

形式文法

isolation = 
<isolation-mode>

<isolation-mode> =
auto |
isolate

要素で強制的に新しい重ね合わせコンテキストを生成

HTML

html
<div id="b" class="a">
  <div id="d">
    <div class="a c">auto</div>
  </div>
  <div id="e">
    <div class="a c">isolate</div>
  </div>
</div>

CSS

css
.a {
  background-color: rgb(0, 255, 0);
}
#b {
  width: 200px;
  height: 210px;
}
.c {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  padding: 2px;
  mix-blend-mode: difference;
}
#d {
  isolation: auto;
}
#e {
  isolation: isolate;
}

結果

仕様書

Specification
Compositing and Blending Level 2
# isolation

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
isolation

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報