這篇文章給大家分享的是有關(guān)js如何實(shí)現(xiàn)3D圖片環(huán)展示效果的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
為臨潭等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及臨潭網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站制作、成都網(wǎng)站建設(shè)、臨潭網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
可對(duì)整體進(jìn)行拖拽
效果圖:
代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{padding:0;margin:0; font-family: "Proxima Nova","proxima-nova","Helvetica Neue",Helvetica,Arial,sans-serif !important;} html body{overflow: hidden;} body{background:#ccc;} .box{width:140px; height:200px; -webkit-transform-style:preserve-3d; -webkit-transform: perspective(800px) rotateY(0deg) rotateX(0deg); position:relative; margin:400px auto;} .box span{width:140px; height:200px; position: absolute; background:deepskyblue; font-size:20px; text-align: center; line-height:200px; color:white;} </style> <script> function r2n(n){ return n*Math.PI/180 } window.onload=function(){ var oBox=document.getElementsByClassName('box')[0]; var aS=document.getElementsByTagName('span'); for(var i=0;i<aS.length;i++){ aS[i].style.WebkitTransition='1s all ease '+(aS.length-i)*.1+'s'; aS[i].style.WebkitTransform='rotateY('+i*360/aS.length+'deg)'+' translateZ(500px) ' } var pos=[]; var x=0; var y=0; var timer=null; var timer2=null; document.onmousedown=function(ev){ timer=setInterval(function(){ pos[0]=pos[2]; pos[1]=pos[3]; pos[2]=x; pos[3]=y; },30); var disx=ev.pageX-x; var disy=ev.pageY-y; document.onmousemove=function(ev){ x=ev.pageX-disx; y=ev.pageY-disy; oBox.style.WebkitTransform=' perspective(800px)'+' rotateY('+x/3+'deg)'+'rotateX('+-y/3+'deg)'; }; document.onmouseup=function(){ clearInterval(timer); var speedx=pos[2]-pos[0]; var speedy=pos[3]-pos[1]; timer2=setInterval(function(){ x+=speedx; y+=speedy; oBox.style.WebkitTransform=' perspective(800px)'+' rotateY('+x/3+'deg)'+'rotateX('+-y/3+'deg)'; speedx*=0.94; speedy*=0.94; if(Math.abs(speedx)<1)speedx=0; if(Math.abs(speedy)<1)speedy=0; if(speedx==0&&speedy==0){ clearInterval(timer2) } },30); document.onmousemove=null; document.onmouseup=null; } }; return false } </script> </head> <body> <div class="box"> <span>1</span> <span>2</span> <span>3</span> <span>4</span> <span>5</span> <span>6</span> <span>7</span> <span>8</span> <span>9</span> <span>10</span> <span>11</span> <span>12</span> </div> </body> </html>
感謝各位的閱讀!關(guān)于“js如何實(shí)現(xiàn)3D圖片環(huán)展示效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
文章標(biāo)題:js如何實(shí)現(xiàn)3D圖片環(huán)展示效果
文章出自:http://bm7419.com/article40/gijoho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、外貿(mào)建站、搜索引擎優(yōu)化、虛擬主機(jī)、網(wǎng)站建設(shè)、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)