您好,登錄后才能下訂單哦!
這篇文章主要介紹如何解決CSS3旋轉(zhuǎn)立方體問題,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
3D坐標概念
當(dāng)元素進行旋轉(zhuǎn)時,他的坐標軸也跟著他進行旋轉(zhuǎn)
注意-y方向問題
旋轉(zhuǎn)立方體的效果
分析
一個容器包含6個div
position:absolute 之后6個面完全重合
通過trandform:rotateX/Y/Z(),translateX/Y/Z()調(diào)整到相應(yīng)位置
添加transition動畫效果
注意這里面的旋轉(zhuǎn)是繞著他的中心線進行旋轉(zhuǎn)的所以唯一100px
他在旋轉(zhuǎn)時,他的坐標軸也是跟著他進行旋轉(zhuǎn)的(這很重要)
代碼
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> *{ margin: 0px; padding: 0px; } body{ perspective: 800px; background: #000000; } #container{ height: 200px; width: 200px; margin: 100px auto 0; position: relative; transform-style: preserve-3d; animation: move 1s ease infinite; } @keyframes move{ from{ transform: rotateY(0deg) rotateZ(0deg); } to{ transform: rotateY(360deg) rotateZ(360deg); } } #container>div{ height: 100%; width: 100%; border-radius: 5px; background: rgba(255,255,255,0.5); position: absolute; left: 0px; right: 0px; text-align: center; line-height: 200px; font-size: 30px; } #one{ transform:rotateX(-90deg) translateZ(100px); } #two{ transform:translateZ(100px) ; } #three{ transform: rotateY(-90deg) translateZ(100px); } #four{ transform: rotateY(-180deg) translateZ(100px); } #five{ transform: rotateY(90deg) translateZ(100px); } #six{ transform: translateZ(-100px); } </style> </head> <body> <div id="container"> <div id="one">1</div> <div id="two">2</div> <div id="three">3</div> <div id="four">4</div> <div id="five">5</div> <div id="six">6</div> </div> </body> </html>
以上是“如何解決CSS3旋轉(zhuǎn)立方體問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。