Result Size: 625 x 534
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
.a {
  background-color: lightgreen;
}
#b {
  width: 250px;
  height: 250px;
}
.c {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  padding: 2px;
  mix-blend-mode: difference;
}
#d {
  isolation: auto;
}
</style>
</head>
<body>
<h1>使用 JavaScript 更改隔离</h1>
<p>单击“试一试”按钮更改 div“d”的 isolation 隔离属性。</p>
<button onclick="myFunction()">试一试</button>
<div id="b" class="a">
  <div id="d">
  <div class="a c">div d</div>
  </div>
</div>
<script>
function myFunction() {
  document.getElementById("d").style.isolation = "isolate";
}
</script>
<p><b>注意:</b> Internet Explorer 11 及更早版本不支持隔离属性 isolation。</p>