blob: 1f5ecf3f29b8f0cc6fc2a45622792a4752be7373 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
---
title: isolation
slug: Web/CSS/isolation
tags:
- CSS
- CSS参考
- CSS属性
- CSS混合
- 布局
translation_of: Web/CSS/isolation
---
<p>{{CSSRef()}}</p>
<h2 id="Summary" name="Summary">概述</h2>
<p><code>isolation</code> CSS属性定义该元素是否必须创建一个新的层叠上下文({{glossary("stacking context")}})。</p>
<p>该属性的主要作用是当和{{cssxref("background-blend-mode")}}属性一起使用时,可以只混合一个指定元素栈的背景:它允许使一组元素从它们后面的背景中独立出来,只混合这组元素的背景。</p>
<p>{{cssinfo}}</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="twopartsyntaxbox"><code>Formal syntax: {{csssyntax("isolation")}}</code></pre>
<pre>isolation: auto;
isolation: isolate;
isolation: initial;
isolation: inherit;
isolation: unset;
</pre>
<h3 id="Values" name="Values">值</h3>
<dl>
<dt><code>auto</code></dt>
<dd>该关键字定义只有在该元素的属性需要的时候才会创建一个新的元素栈环境。</dd>
<dt><code>isolate</code></dt>
<dd>该关键字定义一个新的元素栈环境会被创建。</dd>
</dl>
<h2 id="示例">示例</h2>
<pre class="brush: 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>
</pre>
<pre class="brush: 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;
}</pre>
<p>{{ EmbedLiveSample('%E7%A4%BA%E4%BE%8B', "230", "230") }}</p>
<h2 id="Examples" name="Examples">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ SpecName('Compositing', '#isolation', 'Isolation') }}</td>
<td>{{ Spec2('Compositing') }}</td>
<td>首次定义</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
{{Compat("css.properties.isolation")}}
<h2 id="See_also" name="See_also">参见</h2>
<ul>
<li>{{cssxref("<blend-mode>")}}</li>
<li>{{cssxref("mix-blend-mode")}}, {{cssxref("background-blend-mode")}}</li>
</ul>
|