Created
October 22, 2024 05:07
-
-
Save kyktommy/a57a217b8feb712d97b996926fcf7740 to your computer and use it in GitHub Desktop.
z-index test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>z-index test</title> | |
| <style> | |
| .container { | |
| position: relative; | |
| background-color: rgba(0, 0, 0, 0.2); | |
| } | |
| .box-1-parent { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 200px; | |
| height: 200px; | |
| background-color: rgba(255, 0, 0, 1); | |
| } | |
| .box-1-child { | |
| position: absolute; | |
| top: 50px; | |
| left: 0; | |
| width: 100px; | |
| height: 100px; | |
| background-color: rgba(255, 255, 0, 1); | |
| z-index: 6; | |
| } | |
| .box-1-child2 { | |
| position: absolute; | |
| top: 50px; | |
| left: 50px; | |
| width: 100px; | |
| height: 100px; | |
| background-color: rgba(255, 0, 255, 1); | |
| z-index: 9999; | |
| } | |
| .box-2-parent { | |
| position: absolute; | |
| top: 20px; | |
| left: 20px; | |
| width: 200px; | |
| height: 200px; | |
| background-color: blue; | |
| z-index: 5; | |
| } | |
| .box-2-child { | |
| position: absolute; | |
| top: 50px; | |
| left: 0; | |
| width: 100px; | |
| height: 100px; | |
| background-color: rgba(120, 255, 0, 1); | |
| } | |
| .box-2-child2 { | |
| position: absolute; | |
| top: 80px; | |
| left: 50px; | |
| width: 100px; | |
| height: 100px; | |
| background-color: rgba(0, 255, 255, 1); | |
| z-index: 10; | |
| } | |
| .box-deep-parent { | |
| width: 200px; | |
| height: 200px; | |
| background-color: rgba(0, 0, 255, 1); | |
| } | |
| .box-deep-child { | |
| position: relative; | |
| width: 50px; | |
| height: 50px; | |
| background-color: black; | |
| z-index: 99999999; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"></div> | |
| <div class="box-1-parent"> | |
| <div class="box-1-child"></div> | |
| <div class="box-1-child2"></div> | |
| </div> | |
| <div class="box-2-parent"> | |
| <div class="box-2-child"></div> | |
| <div class="box-2-child2"></div> | |
| </div> | |
| <div> | |
| <div> | |
| <div class="box-deep-parent"> | |
| <div class="box-deep-child"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment