這篇文章帶給大家的內容是關於如何使用css3實現魔術方塊的動畫效果(完整程式碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。
<!DOCTYPE html> <html> <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: 0; padding: 0; } .box{ width: 300px; height: 300px; margin: 100px auto; position: relative; transform-style: preserve-3d; transform: rotateX(-30deg) rotateY(30deg); animation: updown 3s linear 3s infinite alternate; } @keyframes updown{ 0%{ transform: rotateX(-30deg) rotateY(30deg); } 100%{ transform: rotateX(360deg) rotateY(360deg); } } ul{ list-style: none; } .box li{ width: 100px; height: 100px; border: 2px solid #fff; box-sizing: border-box; float: left; position: relative; } .box>div{ position: absolute; width: 100%; height: 100%; opacity: 0.5 } .box .front{ /*background-color: deeppink;*/ transform: translateZ(150px); } .box .behind{ /*background-color: yellow;*/ transform: translateZ(-150px); } .box .left{ /*background-color: greenyellow;*/ transform: rotateY(-90deg) translateZ(150px); } .box .right{ /*background-color: red;*/ transform: rotateY(90deg) translateZ(150px); } .box .top{ /*background-color: deepskyblue;*/ transform: rotateX(90deg) translateZ(150px); } .box .bottom{ /*background-color: purple;*/ transform: rotateX(-90deg) translateZ(150px); } </style> </head> <body> <div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <script src="jquery.js"></script> <script> var box = $(".box"); var divs = box.children(); var lisColor = ['deeppink','yellow','greenyellow','red','deepskyblue','purple'] divs.each(function(index,el){ var ul = $("<ul></ul>"); for(var i = 0; i < 9; i++){ var li = $("<li></li>"); li.css({"backgroundColor":lisColor[index]}); ul.append(li); } $(el).append(ul); }); var lisPosition = []; for(var i = 0; i < 54; i++){ lisPosition.push(parseInt(Math.random()*350)); } $('li').each(function(index,el){ $(el).css({'left':lisPosition[index],"top":lisPosition[index]}); }) $('li').each(function(index,el){ $(el).animate({'left':0,"top":0},3000); }) </script> </body> </html>
相關推薦:
#以上是如何使用css3實現魔術方塊的動畫效果(完整程式碼)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(John Rhea)挑選了他寫的一個舊的CSS動畫,並介紹了優化它的思維過程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcsssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingMultatingMultationMultationProperPertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用CombanningWiThjavoFofofofoftofofo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他們可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑戰挑戰InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)創造性

使用滾動陰影,尤其是對於移動設備,是克里斯以前涵蓋的一個微妙的UX。傑夫(Geoff)涵蓋了一種使用動畫限制屬性的新方法。這是另一種方式。


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

WebStorm Mac版
好用的JavaScript開發工具

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

Dreamweaver CS6
視覺化網頁開發工具