這篇文章主要介紹如何解決CSS3旋轉(zhuǎn)立方體問題,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)與策劃設(shè)計,禹城網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:禹城等地區(qū)。禹城做網(wǎng)站價格咨詢:13518219792
3D坐標(biāo)概念
當(dāng)元素進(jìn)行旋轉(zhuǎn)時,他的坐標(biāo)軸也跟著他進(jì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)是繞著他的中心線進(jìn)行旋轉(zhuǎn)的所以唯一100px
他在旋轉(zhuǎn)時,他的坐標(biāo)軸也是跟著他進(jì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)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章題目:如何解決CSS3旋轉(zhuǎn)立方體問題
文章網(wǎng)址:http://chinadenli.net/article46/ggjphg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、網(wǎng)頁設(shè)計公司、網(wǎng)站排名、網(wǎng)站營銷、手機(jī)網(wǎng)站建設(shè)、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)