With CSS, how can perform animation on z-index property?
To implement animation on z-index property with CSS, you can try to run the following code
Live Demo
<!DOCTYPE html> <html> <head> <style> div { position: absolute; } #box div { background-color: orange; border: 2px solid yellow; width: 100px; height: 100px; opacity: 0.3; } div#demo { opacity: 1; background-color: coral; z-index: 1; animation: myanim 3s; } @keyframes myanim { 30% { z-index: 3; } } </style> </head> <body> <h1>CSS z-index property</h1> <div id = "box"> <div id = "demo"></div> <div style = "top:20px;left:20px;z-index:1;">One</div> <div style = "top:40px;left:40px;z-index:2;">Two</div> <div style = "top:60px;left:60px;z-index:3;">Three</div> <div style = "top:80px;left:80px;z-index:4;">Four</div> <div style = "top:100px;left:40px;z-index:5;">Five</div> <div style = "top:120px;left:60px;z-index:6;">Six</div> <div style = "top:140px;left:80px;z-index:7;">Seven</div> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more