| <!DOCTYPE html> | |
| <!-- | |
| | Like all positioned elements, relatively positioned elements should | |
| | participate in stacking contexts, and thus be eligible to set z-index. | |
| | https://www.w3.org/TR/CSS21/visuren.html#relative-positioning | |
| --> | |
| <html> | |
| <head> | |
| <style> | |
| .box { | |
| width: 50px; | |
| height: 50px; | |
| background-color: rgb(100, 100, 255); | |
| } | |
| .position-absolute-1 { | |
| position: absolute; | |
| left: 25px; | |
| top: 35px; | |
| width: 90px; | |
| height: 90px; | |
| background-color: rgb(100, 255, 100); | |
| z-index: 1; | |
| } | |
| .position-absolute-2 { | |
| position: absolute; | |
| left: 45px; | |
| top: 35px; | |
| width: 90px; | |
| height: 90px; | |
| background-color: rgb(255, 100, 255); | |
| z-index: 3; | |
| } | |
| .position-relative { | |
| position: relative; | |
| left: 25px; | |
| top: 25px; | |
| background-color: rgb(255, 100, 100); | |
| z-index: 2; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="box"></div> | |
| <div class="position-absolute-1"></div> | |
| <div class="position-absolute-2"></div> | |
| <div class="box position-relative"></div> | |
| <div class="box"></div> | |
| </body> | |
| </html> |