CKTIS / CSS
CSS-Eigenschaft `isolation`
`isolation` mit isolate erzwingt einen neuen Stapelkontext und hält Mischung sowie z-index der Nachkommen innerhalb dieses Kontexts.
Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Syntax
auto | isolateisolation mit isolate erzwingt einen neuen Stapelkontext und hält Mischung sowie z-index der Nachkommen innerhalb dieses Kontexts.
Das Beispiel überlagert einen Nachkommen mit hohem z-index und ein Geschwister und prüft elementFromPoint vor und nach isolate.
Der Anfangswert ist auto; die Eigenschaft wird nicht vererbt. Außerdem: Prozentwerte gelten nicht; das Modul bestimmt die Interpolation.
Der neue Kontext ändert nicht die z-index-Reihenfolge seiner Nachkommen, sondern trennt nur den Vergleich mit äußeren Elementen. auto erzeugt nur aus anderen Gründen einen Kontext.
Beispiele
<!doctype html>
<html lang="en"><meta charset="utf-8"><title>CKTIS CSS reference example</title>
<body><div class="probe">probe</div><pre id="result"></pre><script>
document.body.innerHTML = '<div id="group"><div id="high"></div></div><div id="sibling"></div><pre id="result"></pre>';
const group = document.querySelector("#group");
const high = document.querySelector("#high");
const sibling = document.querySelector("#sibling");
group.style.cssText = "position:absolute;left:0;top:0;width:40px;height:40px";
high.style.cssText = "position:absolute;inset:0;z-index:10";
sibling.style.cssText = "position:absolute;left:0;top:0;width:40px;height:40px;z-index:1";
const before = document.elementFromPoint(20,20).id;
group.style.isolation = "isolate";
const after = document.elementFromPoint(20,20).id;
document.querySelector("#result").textContent = "top=" + before + "->" + after + "; computed=" + getComputedStyle(group).isolation;
</script></body></html>Ergebnis
top=high->sibling; computed=isolate
Das Beispiel lief lokal in einer isolierten Chrome-Sitzung ohne Netzwerk; das Ergebnis stammt aus der CSS-API des Browsers.