Beispiel:CSS2 z-index2.html
Aus SELFHTML-Wiki
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css" >
<title>z-index im eigenen Stapelkontext</title>
<style>
.blau {
z-index: 1;
}
.gold {
z-index: 2147483646;
}
/* -------- */
div {
position: absolute;
width: 8em;
aspect-ratio: 1/1;
}
.blau {
top: 4em;
left: 4em;
background: steelblue;
}
.gold {
top: 6em;
left: 6em;
background: gold;
border: thin solid steelblue;
}
.wrapper {
position: relative;
z-index: 0;
}
main {position:relative;}
p {margin-top:8em;}
</style>
</head>
<body>
<h1>Verwendung von <code>z-index</code></h1>
<main>
<div class="blau"></div>
<div class="wrapper">
<div class="gold"></div>
</div>
</main>
<p>Warum ist die goldene Box trotz <code>z-index: 2147483646;</code> unterhalb der blauen Box?</p>
</body>
</html>