isolation CSS property determines whether an element must create a new stacking context .

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

This property is especially helpful when used in conjunction with mix-blend-mode .

句法

/* Keyword values */
isolation: auto;
isolation: isolate;
/* Global values */
isolation: inherit;
isolation: initial;
isolation: unset;
					

isolation property is specified as one of the keyword values listed below.

auto

A new stacking context is created only if one of the properties applied to the element requires it.

isolate

A new stacking context must be created.

形式定义

初始值 auto
适用于 All elements. In SVG, it applies to container elements, graphics elements, and graphics referencing elements.
继承 no
计算值 如指定
动画类型 discrete

形式句法

auto | isolate
					

范例

Forcing a new stacking context for an element

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

.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;
}
					

结果

规范

规范 状态 注释
Compositing and Blending Level 1
The definition of 'Isolation' in that specification.
候选推荐 初始定义

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
isolation Chrome 完整支持 41 Edge 完整支持 79 Firefox 完整支持 36 IE 不支持 No Opera 完整支持 30 Safari 完整支持 8 WebView Android 完整支持 41 Chrome Android 完整支持 41 Firefox Android 完整支持 36 Opera Android 完整支持 30 Safari iOS 完整支持 8 Samsung Internet Android 完整支持 4.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: