搜尋
首頁web前端前端問答教你一招實現3D圖片演示

本篇文章給大家詳細介紹一下製作3D圖片的方法。有一定的參考價值,有需要的朋友可以參考一下,希望對大家有幫助。

教你一招實現3D圖片演示

1、建立一個父容器,將所有照片疊在一起

程式碼如下(html):

  <div>
      <!-- 父容器,相当于把所有图片都放在一起 -->
    <div>
      <img  src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="2.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="3.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="4.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="5.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="6.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      <img  src="/static/imghwm/default1.png" data-src="8.jpg" class="lazy" alt="教你一招實現3D圖片演示" >

      <a>
        <img  src="/static/imghwm/default1.png" data-src="7.jpg" class="lazy" alt="教你一招實現3D圖片演示" >
      </a>
  

      <!-- <video controls autoplay="autoplay" loop>
        <source src="8.jpg" type="video/mp4">
      </video> -->

      <p>3D Tiktok Carousel</p>
    </div>
    <div></div>
  </div>

2、給所有照片加上旋轉動畫

程式碼如下(js):

function init(delayTime) {
  // 给所有的图片加动画
  for (var i = 0; i <h2 id="監聽滑鼠事件">3、監聽滑鼠事件</h2><p>程式碼如下(js):</p><pre class="brush:php;toolbar:false">// 滚轮滚动
// 监听鼠标滚轮事件,该函数不用调用直接生效
document.onmousewheel = function(e){
    // console.log(e)
    e = e || window.event
    var d  = e.wheelDelta / 10 || -e.detail
    radius += d
    init(1)

} 
var sX,sY,nX,nY,desX = 0 , desY = 0, tX = 0,tY = 0;
// 鼠标拖动页面
document.onpointerdown = function(e){
    // console.log(e);
    e = e || window.event//防止出错,如果e不存在,则让window.event为e
    var sX = e.clientX,
    sY = e.clientY
    //监听鼠标移动函数
    this.onpointermove = function(e){
        console.log(e);
        e = e || window.event//防止出错,如果e不存在,则让window.event为e
        var nX = e.clientX,
            nY = e.clientY;
        desX = nX - sX;//在x轴上滑动的距离
        desY = nY - sY;
        tX += desX * 0.1
        tY += desY * 0.1
        // 让页面跟着鼠标动起来
        applyTransform(oDarg)
    }
    this.onpointerup = function(e){
        //每个多久实现一次setInterval
        oDarg.timer = setInterval(function(){
            desX *= 0.95
            desY *= 0.95
            tX += desX * 0.1
            tY += desY * 0.1
            applyTransform(oDarg)
            playSpin(false)
            if(Math.abs(desX)  180)tY = 180
    if(tY <p> 【推薦學習:<a href="https://www.php.cn/course/list/2.html" target="_blank">javascript高階教學</a>】</p>

以上是教你一招實現3D圖片演示的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
CSS:我可以在同一DOM中使用多個ID嗎?CSS:我可以在同一DOM中使用多個ID嗎?May 14, 2025 am 12:20 AM

No,youshouldn'tusemultipleIDsinthesameDOM.1)IDsmustbeuniqueperHTMLspecification,andusingduplicatescancauseinconsistentbrowserbehavior.2)Useclassesforstylingmultipleelements,attributeselectorsfortargetingbyattributes,anddescendantselectorsforstructure

HTML5的目的:創建一個更強大,更容易訪問的網絡HTML5的目的:創建一個更強大,更容易訪問的網絡May 14, 2025 am 12:18 AM

html5aimstoenhancewebcapabilities,Makeitmoredynamic,互動,可及可訪問。 1)ITSupportsMultimediaElementsLikeAnd,消除innewingtheneedtheneedtheneedforplugins.2)SemanticeLelelemeneLementelementsimproveaCceccessibility inmproveAccessibility andcoderabilitile andcoderability.3)emply.3)lighteppoperable popperappoperable -poseive weepivewebappll

HTML5的重要目標:增強網絡開發和用戶體驗HTML5的重要目標:增強網絡開發和用戶體驗May 14, 2025 am 12:18 AM

html5aimstoenhancewebdevelopmentanduserexperiencethroughsemantstructure,多媒體綜合和performanceimprovements.1)SemanticeLementLike like,和ImproVereAdiability and ImproVereAdabilityActibility.2)and tagsallowsemlessallowseamelesseamlessallowseamelesseamlesseamelesseamemelessmultimedimeDiaiaembediiaembedplugins.3)。 3)3)

HTML5:安全嗎?HTML5:安全嗎?May 14, 2025 am 12:15 AM

html5isnotinerysecure,butitsfeaturescanleadtosecurityrisksifmissusedorimproperlyimplempled.1)usethesand andboxattributeIniframestoconoconoconoContoContoContoContoContoconToconToconToconToconToconTedContDedContentContentPrenerabilnerabilityLikeClickLickLickLickjAckJackJacking.2)

與較舊的HTML版本相比,HTML5目標與較舊的HTML版本相比,HTML5目標May 14, 2025 am 12:14 AM

HTML5aimedtoenhancewebdevelopmentbyintroducingsemanticelements,nativemultimediasupport,improvedformelements,andofflinecapabilities,contrastingwiththelimitationsofHTML4andXHTML.1)Itintroducedsemantictagslike,,,improvingstructureandSEO.2)Nativeaudioand

CSS:使用ID選擇器不好嗎?CSS:使用ID選擇器不好嗎?May 13, 2025 am 12:14 AM

使用ID選擇器在CSS中並非固有地不好,但應謹慎使用。 1)ID選擇器適用於唯一元素或JavaScript鉤子。 2)對於一般樣式,應使用類選擇器,因為它們更靈活和可維護。通過平衡ID和類的使用,可以實現更robust和efficient的CSS架構。

HTML5:2024年的目標HTML5:2024年的目標May 13, 2025 am 12:13 AM

html5'sgoalsin2024focusonrefinement和optimization,notNewFeatures.1)增強performanceandeffipedroptimizedRendering.2)inviveAccessibilitywithRefinedwithRefinedTributesAndEllements.3)explityconcerns,尤其是withercercern.4.4)

HTML5試圖改進的主要領域是什麼?HTML5試圖改進的主要領域是什麼?May 13, 2025 am 12:12 AM

html5aimedtotoimprovewebdevelopmentInfourKeyAreas:1)多中心供應,2)語義結構,3)formcapabilities.1)offlineandstorageoptions.1)html5intoryements html5introctosements introdements and toctosements and toctosements,簡化了inifyingmediaembedingmediabbeddingingandenhangingusexperience.2)newsements.2)

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具