如果对css-3d部分的基础知识不清楚,请参考http://acgtofe.com/posts/2013/09/css-3d-transform以及http://acgtofe.com/posts/2015/12/xyz-3d-in-css
1 2 3 4 5 6 7 8 9 10
| <div class="view"> <div class="box"> <div class="one">A</div> <div class="two">B</div> <div class="three">C</div> <div class="four">D</div> <div class="five">E</div> <div class="six">F</div> </div> </div>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| <style> .view{ margin: 80px auto; width: 160px; height: 160px; } .box{ width: 160px; position:relative; transform-style: preserve-3d; transform-origin: 80px 80px 0; transform: rotateX(20deg);
animation-name: animation; animation-duration: 10s; animation-timing-function: ease-in-out; animation-iteration-count:infinite; } .box div{ position: absolute; width: 160px; height: 160px; background: rgba(255,200,100,0.4); line-height: 160px; text-align: center; font-size: 130px; border: 1px solid #000; }
.one{ transform: translateZ(80px); } .two{ transform: rotateX(-90deg) translateZ(80px); } .three { transform: rotateX(90deg) translateZ(80px); } .four{ transform: rotateX(180deg) translateZ(80px); } .five{ transform: rotateY(-90deg) translateZ(80px) } .six{ transform: rotateY(90deg) translateZ(80px) }
@-webkit-keyframes animation { from,to{} 16% { -webkit-transform: rotateY(-90deg);} 33% { -webkit-transform: rotateY(-90deg) rotateZ(135deg);} 50% { -webkit-transform: rotateY(225deg) rotateZ(135deg);} 66% { -webkit-transform: rotateY(135deg) rotateX(135deg);} 83% { -webkit-transform: rotateX(135deg);} } </style>
|