這篇文章主要為大家展示了“如何使用css實(shí)現(xiàn)3D圖像輪轉(zhuǎn)效果”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何使用css實(shí)現(xiàn)3D圖像輪轉(zhuǎn)效果”這篇文章吧。
專注于為中小企業(yè)提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)圖們免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
首先看html文件,div.billboard為效果的容器,利用10個(gè)div.poster分割圖像,每個(gè)poster中有三個(gè)face,分別用來承載三個(gè)圖像。
XML/HTML Code復(fù)制內(nèi)容到剪貼板
<div class="billboard">
<div class="poster">
<div class="face panel1 p1"></div>
<div class="face panel2 p1"></div>
<div class="face panel3 p1"></div>
</div>
<div class="poster">
<div class="face panel1 p2"></div>
<div class="face panel2 p2"></div>
<div class="face panel3 p2"></div>
</div>
<div class="poster">
<div class="face panel1 p3"></div>
<div class="face panel2 p3"></div>
<div class="face panel3 p3"></div>
</div>
<div class="poster">
<div class="face panel1 p4"></div>
<div class="face panel2 p4"></div>
<div class="face panel3 p4"></div>
</div>
<div class="poster">
<div class="face panel1 p5"></div>
<div class="face panel2 p5"></div>
<div class="face panel3 p5"></div>
</div>
<div class="poster">
<div class="face panel1 p6"></div>
<div class="face panel2 p6"></div>
<div class="face panel3 p6"></div>
</div>
<div class="poster">
<div class="face panel1 p7"></div>
<div class="face panel2 p7"></div>
<div class="face panel3 p7"></div>
</div>
<div class="poster">
<div class="face panel1 p8"></div>
<div class="face panel2 p8"></div>
<div class="face panel3 p8"></div>
</div>
<div class="poster">
<div class="face panel1 p9"></div>
<div class="face panel2 p9"></div>
<div class="face panel3 p9"></div>
</div>
<div class="poster">
<div class="face panel1 p10"></div>
<div class="face panel2 p10"></div>
<div class="face panel3 p10"></div>
</div>
</div>
CSS文件這里我們用到了sass,用的是scss語法。
CSS Code復(fù)制內(nèi)容到剪貼板
//變量初始化
//圖像分塊個(gè)數(shù),如要更改,html需要進(jìn)行相應(yīng)的修改
$numPoster:10;
//輪換圖像個(gè)數(shù),如要更改,html需要進(jìn)行相應(yīng)的修改
$numFace:3;
//圖像寬度
$width:600px;
//圖像高度
$height:320px;
//盒子的設(shè)置
.billboard {
width:$width;
margin:100px auto;
}
//圖像條左浮動(dòng)
.poster {
float:left;
width:$width/$numPoster;
height:$height;
}
//圖像條面的統(tǒng)一設(shè)置,絕對定位、3d動(dòng)畫設(shè)置
.face {
position:absolute;
height:$height;
width:$width/$numPoster;
transform-origin:50% 50% -17px;
backface-visibility: hidden;
transform-style:preserve-3d;
perspective:350px;
}
//圖像條面分別設(shè)置背景圖像、動(dòng)畫
@for $i from 1 through $numFace{
.poster .panel#{$i} {
background:url(http://gx.zptc.cn/whqet/img/#{$i}.jpg);
transform:transformY(360deg/$numFace*($i - 1));
animation: rotateMe#{$i} 10s infinite;
}
@keyframes rotateMe#{$i} {
0% {
transform:rotateY(360deg/$numFace*($i - 1));
}
9% {
transform:rotateY(360deg/$numFace*($i - 1));
}
24% {
transform:rotateY(360deg/$numFace*($i));
}
42% {
transform:rotateY(360deg/$numFace*($i));
}
57% {
transform:rotateY(360deg/$numFace*($i + 1));
}
75% {
transform:rotateY(360deg/$numFace*($i + 1));
}
90% {
transform:rotateY(360deg/$numFace*($i + 2));
}
100% {
transform:rotateY(360deg/$numFace*($i + 2));
}
}
}
//圖像條面的背景偏移
@for $i from 1 through $numPoster {
.poster .p#{$i} {background-position:-($width/$numPoster*($i - 1)) top;}
}
以上是“如何使用css實(shí)現(xiàn)3D圖像輪轉(zhuǎn)效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
本文題目:如何使用css實(shí)現(xiàn)3D圖像輪轉(zhuǎn)效果
文章路徑:http://aaarwkj.com/article48/pjdpep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、手機(jī)網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、微信小程序、定制開發(fā)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)