| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>043 relative z-index</title>
- <style>
- html, body { margin: 0; padding: 0; background: #ffffff; color: #202020; }
- body { font-family: sans-serif; font-size: 13px; padding: 10px; }
- h1 { font-size: 20px; margin: 0 0 6px 0; }
- p { margin: 0 0 10px 0; }
- .pane { float: left; width: 440px; margin-left: 10px; }
- .label { background: #eeeeee; padding: 4px 6px; margin-bottom: 4px; }
- .stage { position: relative; width: 260px; height: 220px;
- background: #f4f4f4; border: 1px solid #999999; }
- .red { position: relative; left: 20px; top: 20px; width: 120px; height: 100px;
- background: #cc3333; }
- .blue { position: relative; left: 60px; top: -60px; width: 120px; height: 100px;
- background: #3366cc; }
- .z2 { z-index: 2; }
- .z1 { z-index: 1; }
- </style>
- </head>
- <body>
- <h1>043 · relative z-index</h1>
- <p>A: red has z-index 2, blue has z-index 1, so red wins the overlap. B: the same DOM order without z-index paints blue last.</p>
- <div class="pane">
- <div class="label">A · z-index: red 2, blue 1</div>
- <div class="stage">
- <div class="red z2"></div>
- <div class="blue z1"></div>
- </div>
- </div>
- <div class="pane">
- <div class="label">B · no z-index (DOM order)</div>
- <div class="stage">
- <div class="red"></div>
- <div class="blue"></div>
- </div>
- </div>
- </body>
- </html>
|