Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
擊右上方紅色按鈕關(guān)注“web秀”,讓你真正秀起來
最近公司實(shí)在是太忙了,996的日子(當(dāng)前時(shí)間凌晨2019-01-06 02:04),所以更新也少了,希望大家多體諒一下,在此對(duì)小伙伴們說聲抱歉。
前幾天接到小伙伴投稿,希望做一個(gè)類似loading的效果,也是只要手頭有空就趕緊寫寫,今天終于給做好了,非常感謝"月球居民愛麗絲"的投稿。
原件預(yù)覽圖:
從效果而言,我們主要實(shí)現(xiàn)下列步驟: 1、讓一個(gè)圓旋轉(zhuǎn),并且是先快后慢; 2、有顏色過渡效果、并且有透明度; 3、然后就是復(fù)制上面的效果,5個(gè),然后按時(shí)間執(zhí)行動(dòng)畫
好了,開始我們的表演
css畫一個(gè)圓很簡(jiǎn)單,div設(shè)置寬高,用border-radius:100%就可以輕松實(shí)現(xiàn)。但是實(shí)現(xiàn)一個(gè)圓,旋轉(zhuǎn),并且不是繞自己的圓心旋轉(zhuǎn)(繞自己的圓心旋轉(zhuǎn)看不出來效果)是個(gè)問題,怎么解決了?
看看我的解決方案:
<div class="shadow-box box1"> <div class="shadow"></div> </div>
用一個(gè)盒子,裝住圓,盒子比圓大。圓最水平居中,盒子頂部,然后旋轉(zhuǎn)盒子,就可以搞定圓的選擇效果。
.shadow-box{ position: absolute; width: 260px; height: 260px; border: 1px solid; left: 200px; } .shadow-box div{ position: absolute; background: #1199ff; width: 50px; height: 50px; border-radius: 100%; float: right; left: 50%; margin-left: -25px; } @keyframes trotate{ /*動(dòng)畫開始第一幀*/ from { /*transform: rotate旋轉(zhuǎn),2.4s內(nèi)從0°過渡到360°*/ transform: rotate(0deg); } /*動(dòng)畫結(jié)束最后一幀*/ to { transform: rotate(360deg); } } .box1{ /*動(dòng)畫:2.4s執(zhí)行完畢,cubic-bezier貝塞爾曲線(先快后慢)*/ animation: trotate 2.4s cubic-bezier(.23,1.02,.44,.9); }
顏色過渡和旋轉(zhuǎn)基本一樣,不過顏色并不是作用盒子,而是圓。所以,我們操作box下面的div,添加顏色過渡動(dòng)畫,并添加透明度。
@keyframes acolor1{ from { background: #1199ff; opacity: 0.7; } to { background: #c837ed; opacity: 0.2; } } .box1 div{ animation: acolor1 2.4s cubic-bezier(.23,1.02,.44,.9); background: #1199ff; opacity: 0.7; }
<div class="loading"> <div class="shadow-box box1"> <div class="shadow"></div> </div> <div class="shadow-box box2"> <div class="shadow"></div> </div> <div class="shadow-box box3"> <div class="shadow"></div> </div> <div class="shadow-box box4"> <div class="shadow"></div> </div> <div class="shadow-box box5"> <div class="shadow"></div> </div> </div>
我們復(fù)制5個(gè),并用box1-box5來區(qū)分
.shadow-box{ position: absolute; width: 260px; height: 260px; /* border: 1px solid; */ /*去掉邊框*/ left: 200px; } .shadow-box div{ position: absolute; width: 50px; height: 50px; border-radius: 100%; float: right; left: 50%; margin-left: -25px; } /*旋轉(zhuǎn)動(dòng)畫*/ @keyframes trotate { from { transform:rotate(0deg); } to { transform:rotate(360deg); } } /*box1顏色、透明度過渡動(dòng)畫*/ @keyframes acolor1 { from { background: #1199ff; opacity: 0.7; } to { background: #c837ed; opacity: 0.2; } } @keyframes acolor2 { from { background: #46b0ff; opacity: 0.7; } to { background: #9e79db; opacity: 0.2; } } @keyframes acolor3 { from { background: #32bbff; opacity: 0.7; } to { background: #f577a8; opacity: 0.2; } } @keyframes acolor4 { from { background: #00dbc2; opacity: 0.7; } to { background: #ff745a; opacity: 0.2; } } @keyframes acolor5 { from { background: #00dbc2; opacity: 0.7; } to { background: #ff745a; opacity: 0.2; } } /*box1應(yīng)用旋轉(zhuǎn)動(dòng)畫*/ /** * box1 2.4s * box2 2.2s完成 延時(shí)0.6s執(zhí)行 * box3 2s完成 延時(shí)1.2s執(zhí)行 * ... * 時(shí)間依次減少,動(dòng)畫效果也就是越來越快 * 能追上上面一個(gè)動(dòng)畫 */ .box1{ animation: trotate 2.4s cubic-bezier(.23,1.02,.44,.9); z-index: 4; } .box2{ /* 2s完成 */ animation: trotate 2.2s cubic-bezier(.23,1.02,.44,.9); /* 延時(shí)1.2s執(zhí)行 */ animation-delay: .6s; z-index: 3; } .box3{ animation: trotate 2s cubic-bezier(.23,1.02,.44,.9); animation-delay: 1.2s; z-index: 2; } .box4{ animation: trotate 1.8s cubic-bezier(.23,1.02,.44,.9); animation-delay: 1.8s; z-index: 1; } .box5{ animation: trotate 1.6s cubic-bezier(.23,1.02,.44,.9); animation-delay: 2.4s; z-index: 1; } /*box1應(yīng)用顏色、透明度過渡動(dòng)畫*/ .box1 div{ animation: acolor1 2.4s cubic-bezier(.23,1.02,.44,.9); background: #1199ff; opacity: 0.7; } .box2 div{ animation: acolor2 2.2s cubic-bezier(.23,1.02,.44,.9); animation-delay: .6s; background: #46b0ff; opacity: 0.7; } .box3 div{ animation: acolor3 2s cubic-bezier(.23,1.02,.44,.9); animation-delay: 1.2s; background: #32bbff; opacity: 0.7; } .box4 div{ animation: acolor4 1.8s cubic-bezier(.23,1.02,.44,.9); animation-delay: 1.8s; background: #00dbc2; opacity: 0.7; } .box5 div{ animation: acolor4 1.6s cubic-bezier(.23,1.02,.44,.9); animation-delay: 2.4s; background: #00dbc2; opacity: 0.7; }
最終效果預(yù)覽:
還是那句“萬丈高樓平地起”,要善于問題分解,一步一步來,不要想著一口一個(gè)胖子,飯的慢慢吃。按步驟是不是發(fā)現(xiàn)超級(jí)簡(jiǎn)單就可以搞定?
再次感謝"月球居民愛麗絲"同學(xué),也期待更多人的投稿。
陌生人,2019年好好加油,我看好你。
喜歡小編的點(diǎn)擊關(guān)注,了解更多知識(shí)!
源碼地址請(qǐng)點(diǎn)擊下方“了解更多”
loaders.css是Github上一個(gè)使用純粹的css實(shí)現(xiàn)的開源loading動(dòng)畫庫(kù),完全用CSS編寫的加載動(dòng)畫的集合。每個(gè)動(dòng)畫僅限于CSS屬性的一小部分,以避免復(fù)雜的繪畫和布局計(jì)算。下面這張圖是在demo頁面截取的Gif效果圖,可供參考!
就這樣一個(gè)小小的庫(kù)也收獲了9.5k的stars,以下是其倉(cāng)庫(kù)源地址
https://github.com/ConnorAtherton/loaders.css
自由選擇安裝方式進(jìn)行安裝使用
bower install loaders.css
npm i --save loaders.css
1、標(biāo)準(zhǔn)用法
jQuery(可選)
將樣式添加到正確的子div元素
.ball-grid-pulse > div {
background-color: orange;
}
使用2D比例轉(zhuǎn)換
.loader-small .loader-inner {
transform: scale(0.5, 0.5);
}
Loaders.css衍生了很多適用于其它平臺(tái)或框架的優(yōu)秀庫(kù),這些都是受Loaders.css的啟發(fā)而產(chǎn)生的
https://github.com/jonjaques/react-loaders
https://github.com/Hokid/vue-loaders
https://github.com/Masadow
https://github.com/kaermorchen/ember-cli-loaders
https://github.com/gontovnik/DGActivityIndicatorView
https://github.com/varunsridharan/Loaders.CSS-Android-App
Loaders.css是一個(gè)非常出色的loading動(dòng)畫庫(kù),可以將它運(yùn)用到你任何新的或者現(xiàn)有的項(xiàng)目中,性能出眾,定制化,enjoy it!
loaders.css是Github上一個(gè)使用純粹的css實(shí)現(xiàn)的開源loading動(dòng)畫庫(kù),完全用CSS編寫的加載動(dòng)畫的集合。每個(gè)動(dòng)畫僅限于CSS屬性的一小部分,以避免復(fù)雜的繪畫和布局計(jì)算。下面這張圖是在demo頁面截取的Gif效果圖,可供參考!
就這樣一個(gè)小小的庫(kù)也收獲了9.5k的stars,以下是其倉(cāng)庫(kù)源地址
https://github.com/ConnorAtherton/loaders.css
自由選擇安裝方式進(jìn)行安裝使用
bower install loaders.css
npm i --save loaders.css
1、標(biāo)準(zhǔn)用法
jQuery(可選)
將樣式添加到正確的子div元素
.ball-grid-pulse > div {
background-color: orange;
}
使用2D比例轉(zhuǎn)換
.loader-small .loader-inner {
transform: scale(0.5, 0.5);
}
Loaders.css衍生了很多適用于其它平臺(tái)或框架的優(yōu)秀庫(kù),這些都是受Loaders.css的啟發(fā)而產(chǎn)生的
https://github.com/jonjaques/react-loaders
https://github.com/Hokid/vue-loaders
https://github.com/Masadow
https://github.com/kaermorchen/ember-cli-loaders
https://github.com/gontovnik/DGActivityIndicatorView
https://github.com/varunsridharan/Loaders.CSS-Android-App
Loaders.css是一個(gè)非常出色的loading動(dòng)畫庫(kù),可以將它運(yùn)用到你任何新的或者現(xiàn)有的項(xiàng)目中,性能出眾,定制化,enjoy it!
*請(qǐng)認(rèn)真填寫需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。