简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8"><link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <style> div {position: absolute;} #container div { background-color: lightblue; border: 1px solid #333333; width: 100px; height: 100px; opacity: 0.5; } div#myBox { opacity: 1; background-color: coral; z-index: 1; -webkit-animation: mymove 5s infinite linear; /* Chrome, Safari, Opera */ animation: mymove 5s infinite linear; } /* Chrome, Safari, Opera */ @-webkit-keyframes mymove { 50% {z-index: 5;} } /* Standard syntax */ @keyframes mymove { 50% {z-index: 5;} } </style> <body style="position:absolute"> <p>z-index 属性支持动画效果。</p> <p><b>注意:</b>Internet Explorer 9 及更早 IE 版本不支持 CSS 动画。</p> <p>逐步改变 "myBox" 的 z-index 属性 从 1 到 5:<p> <div id="container"> <div id="myBox">myBox</div> <div style="top:20px;left:20px;z-index:1;">z-index 1</div> <div style="top:40px;left:40px;z-index:2;">z-index 2</div> <div style="top:60px;left:60px;z-index:3;">z-index 3</div> <div style="top:80px;left:80px;z-index:4;">z-index 4</div> </div> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: