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. XML在語(yǔ)音合成中的應(yīng)用2. jscript與vbscript 操作XML元素屬性的代碼3. 不要在HTML中濫用div4. HTML5實(shí)戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)5. .NET Framework各版本(.NET2.0 3.0 3.5 4.0)區(qū)別6. ASP基礎(chǔ)入門(mén)第四篇(腳本變量、函數(shù)、過(guò)程和條件語(yǔ)句)7. ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫(xiě)金額)的函數(shù)8. XML入門(mén)的常見(jiàn)問(wèn)題(三)9. php使用正則驗(yàn)證密碼字段的復(fù)雜強(qiáng)度原理詳細(xì)講解 原創(chuàng)10. HTTP協(xié)議常用的請(qǐng)求頭和響應(yīng)頭響應(yīng)詳解說(shuō)明(學(xué)習(xí))
