JS+CSS實(shí)現(xiàn)炫酷光感效果
JS+CSS帶你實(shí)現(xiàn)炫酷光感效果,供大家參考,具體內(nèi)容如下
效果一:(螺旋式沉浸視覺(jué)感受)
效果二:(旋渦式遠(yuǎn)觀視覺(jué)感受)
實(shí)現(xiàn)代碼:
<!DOCTYPE html><html> <head> <meta charset='utf-8'> <title>光感效果</title> </head> <style> html,body{ height: 100%; overflow: hidden; } body{ background-color: #c08eaf; } .main{ /* 中心點(diǎn) */ width: 8px; height: 8px; /* background-color: aqua; */ position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); /* *景深,修改此屬性可獲得如上圖展示的不同效果 *如:圖一的perspective為400px *圖二的perspective為800px *修改為其它值還可獲得更多效果 */ perspective: 800px; } .main i{ /* 動(dòng)點(diǎn) */ width: 8px; height: 8px; border-radius: 50%; background:white; box-shadow: 0 0 10px 0 white; position: absolute; /* 動(dòng)畫(huà) */ animation: run 3s ease-in-out infinite; } /* .main i:nth-child(1){ transform: rotate(0deg) translateX(80px); } */ /* 動(dòng)畫(huà) */ @keyframes run{ 0%{ opacity: 0; } 10%{ opacity: 1; } 100%{ opacity: 1; /* 3D動(dòng)畫(huà)效果 */ transform: translate3d(0,0,560px); } } </style> <body> <div id='main'> </div> </body> <script type='text/javascript'> //獲取元素 var m = document.getElementById('main'); for(var i = 0;i<60;i++){ //創(chuàng)建元素 var newNode = document.createElement('i'); //添加元素 m.appendChild(newNode) //設(shè)置旋轉(zhuǎn)角度 及x軸方向位移距離 newNode.style.transform=`rotate(${i*12}deg) translateX(80px)` //設(shè)置動(dòng)畫(huà)延遲 newNode.style.animationDelay=`${i*0.05}s` } </script></html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Intellij IDEA 2019 最新亂碼問(wèn)題及解決必殺技(必看篇)2. java實(shí)現(xiàn)圖形化界面計(jì)算器3. Android 7.0 運(yùn)行時(shí)權(quán)限彈窗問(wèn)題的解決4. IntelliJ IDEA設(shè)置條件斷點(diǎn)的方法步驟5. 《javascript設(shè)計(jì)模式》學(xué)習(xí)筆記三:Javascript面向?qū)ο蟪绦蛟O(shè)計(jì)單例模式原理與實(shí)現(xiàn)方法分析6. ASP.NET MVC獲取多級(jí)類(lèi)別組合下的產(chǎn)品7. 關(guān)于HTML5的img標(biāo)簽8. ASP.NET MVC解決上傳圖片臟數(shù)據(jù)的方法9. ASP基礎(chǔ)入門(mén)第七篇(ASP內(nèi)建對(duì)象Response)10. 原生js XMLhttprequest請(qǐng)求onreadystatechange執(zhí)行兩次的解決
