查看效果:http://hovertree.com/texiao/css/14/本效果用css3的animation實現動畫定義和用法animation 屬性是一個簡寫屬性,用於設置六個動畫屬性:animation-nameanimation-durationanimation-timing-fun...
查看效果:http://hovertree.com/texiao/css/14/
本效果用css3的animation實現動畫
定義和用法
animation 屬性是一個簡寫屬性,用於設置六個動畫屬性:
animation-name
animation-duration
animation-timing-function
animation-delay
animation-iteration-count
animation-direction
註釋:請始終規定 animation-duration 屬性,否則時長為 0,就不會播放動畫了。
預設值: none 0 ease 0 1 normal
繼承性: no
版本: CSS3
JavaScript 語法: object.style.animation="movehovertree 5s infinite"
語法
animation: name duration timing-function delay iteration-count direction;
animation-name 規定需要綁定到選擇器的 keyframe 名稱。。
animation-duration 規定完成動畫所花費的時間,以秒或毫秒計。
animation-timing-function 規定動畫的速度曲線。
animation-delay 規定在動畫開始之前的延遲。
animation-iteration-count 規定動畫應該播放的次數。
animation-direction 規定是否應該輪流反向播放動畫。
示例:http://hovertree.com/texiao/css/14/1.htm
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>CSS3女神來襲 - 何問起</title> <style> body { margin: 0; background: #000; } #wrap { width: 300px; height: 400px; position: relative; margin: 100px auto; -webkit-perspective: 3000px; -moz-perspective: 3000px; -ms-transform: perspective(3000px); -ms-perspective: 3000px; } #head { width: 100%; height: 100%; position: absolute; -webkit-transform-style: preserve-3d; -webkit-animation: donghua 15s linear 0s infinite; -moz-transform-style: preserve-3d; -moz-animation: donghua 15s linear 0s infinite; -ms-transform-style: preserve-3d; -ms-animation: donghua 25s linear 0s infinite; } #head div { position: absolute; top: 0; left: 0; width: 300px; height: 400px; border: 1px solid red; text-align: center; line-height: 100px; } #head div:nth-child(1) { -webkit-transform: rotateY(0deg) translateZ(400px); -moz-transform: rotateY(0deg) translateZ(400px); -ms-transform: rotateY(0deg) translateZ(400px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/01.jpg); background-size: cover; } #head div:nth-child(2) { -webkit-transform: rotateY(36deg) translateZ(500px); -moz-transform: rotateY(36deg) translateZ(500px); -ms-transform: rotateY(36deg) translateZ(500px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/02.jpg); background-size: cover; } #head div:nth-child(3) { -webkit-transform: rotateY(72deg) translateZ(400px); -moz-transform: rotateY(72deg) translateZ(400px); -ms-transform: rotateY(72deg) translateZ(400px); background: url(http://cms.hovertree.com/hvtimg/201511/9rour12a.jpg); background-size: cover; } #head div:nth-child(4) { -webkit-transform: rotateY(108deg) translateZ(500px); -moz-transform: rotateY(108deg) translateZ(500px); -ms-transform: rotateY(108deg) translateZ(500px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/04.jpg); background-size: cover; } #head div:nth-child(5) { -webkit-transform: rotateY(144deg) translateZ(400px); -moz-transform: rotateY(144deg) translateZ(400px); -ms-transform: rotateY(144deg) translateZ(400px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/05.jpg); background-size: cover; } #head div:nth-child(6) { -webkit-transform: rotateY(180deg) translateZ(500px); -moz-transform: rotateY(180deg) translateZ(500px); -ms-transform: rotateY(180deg) translateZ(500px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/06.jpg); background-size: cover; } #head div:nth-child(7) { -webkit-transform: rotateY(216deg) translateZ(400px); -moz-transform: rotateY(216deg) translateZ(400px); -ms-transform: rotateY(216deg) translateZ(400px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/07.jpg); background-size: cover; } #head div:nth-child(8) { -webkit-transform: rotateY(252deg) translateZ(500px); -moz-transform: rotateY(252deg) translateZ(500px); -ms-transform: rotateY(252deg) translateZ(500px); background: url(http://hovertree.com/texiao/css/14/hovertreepic/08.jpg); background-size: cover; } #head div:nth-child(9) { -webkit-transform: rotateY(288deg) translateZ(400px); -moz-transform: rotateY(288deg) translateZ(400px); -ms-transform: rotateY(288deg) translateZ(400px); background: url(http://hovertree.com/hvtimg/201511/6j9j6tk5.png); background-size: cover; } #head div:nth-child(10) { -webkit-transform: rotateY(324deg) translateZ(500px); -moz-transform: rotateY(324deg) translateZ(500px); -ms-transform: rotateY(324deg) translateZ(500px); background: url(http://cms.hovertree.com/hvtimg/201512/wfevf6yh.jpg); background-size: cover; } @-webkit-keyframes donghua { 0% { transform: rotateX(5deg) rotateY(360deg); } 50% { transform: rotateX(-5deg) rotateY(180deg); } 100% { transform: rotateX(5deg) rotateY(0deg); } } @-moz-keyframes donghua { 0% { transform: rotateY(10deg) rotateY(0deg); } 50% { transform: rotateY(-10deg) rotateY(180deg); } 100% { transform: rotateY(10deg) rotateY(360deg); } } @-ms-keyframes donghua { 0% { transform: rotateY(10deg) rotateY(0deg); } 50% { transform: rotateY(-10deg) rotateY(180deg); } 100% { transform: rotateY(10deg) rotateY(360deg); } }a{color:white} </style> </head> <body> <div id="wrap"> <div id="head"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div><div style="margin:0px auto;text-align:center;width:736px"> <h2>圖片立體旋轉</h2><a href="http://hovertree.com/">首頁</a> <a href="http://hovertree.com/texiao/">特效</a> <a href="http://hovertree.com/h/bjaf/a6598spx.htm">原文</a> <a href="http://hovertree.com/texiao/css/14/1.htm">Demo 2</a></div> </body> </html>
更多: http://www.cnblogs.com/jihua/p/webfront.html