动画CSS z-index属性

要使用CSS在z-index属性上实现动画,您可以尝试运行以下代码-

示例

<!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>