CSS loading效果之 吃豆人的實(shí)現(xiàn)
發(fā)布時(shí)間:2019-09-09 15:43:18 作者:不曾落幕彡
我要評論

這篇文章主要介紹了CSS loading效果之 吃豆人的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
emmm 名字瞎想的2333
前言
這是一個(gè)用來練習(xí)的css demo,如果有哪里寫的不好,還請各位指正,一定虛心接受。嘻嘻
HTML布局
<div class="container"> <div class="loading"> <div class="eat"></div> <div class="load"></div> <div class="load"></div> <div class="load"></div> </div> </div>
CSS 樣式
主要使用了動畫效果,通過不斷控制元素的角度位置實(shí)現(xiàn)一個(gè)類似于吃豆人一樣的loading demo。
body { margin: 0; padding: 0; background: #fff; } .container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .loading { position: relative; width: 200px; height: 50px; display: flex; } .eat { position: relative; width: 50px; height: 50px; left: 0; color: #ff0000; animation: eat-animate 2.4s ease-in-out infinite; } @keyframes eat-animate { 100% { left: 150px; } } .eat::before { content: ''; position: absolute; width: 0; height: 0; width: 50px; height: 25px; top: 0; border-radius: 50px 50px 0 0; background: currentColor; transform: rotate(-30deg); animation: eat-top 2.4s ease-in-out infinite; } @keyframes eat-top { 20% { transform: rotate(-30deg); } 35% { transform: rotate(0deg); } 45% { transform: rotate(-30deg); } 60% { transform: rotate(0deg); } 70% { transform: rotate(-30deg); } 85% { transform: rotate(0deg); } 100% { transform: rotate(0deg); } } .eat::after { content: ''; position: absolute; width: 0; height: 0; width: 50px; height: 25px; bottom: 0; border-radius: 0 0 50px 50px; background: currentColor; transform: rotate(30deg); animation: eat-bottom 2.4s ease-in-out infinite; } @keyframes eat-bottom { 20% { transform: rotate(30deg); } 35% { transform: rotate(0deg); } 45% { transform: rotate(30deg); } 60% { transform: rotate(0deg); } 70% { transform: rotate(30deg); } 85% { transform: rotate(0deg); } 100% { transform: rotate(0deg); } } .load { position: relative; width:30px; height: 30px; margin: 10px; color: #e47272; border-radius: 50%; background: currentColor; } .load:nth-child(2) { animation: load1 2.4s linear infinite; transform: scale(1); } @keyframes load1 { 35% { transform: scale(0); } 100% { transform: scale(0); } } .load:nth-child(3) { animation: load2 2.4s linear infinite; transform: scale(1); } @keyframes load2 { 30% { transform: scale(1); } 58% { transform: scale(0); } 100% { transform: scale(0); } } .load:nth-child(4) { animation: load3 2.4s linear infinite; transform: scale(1); } @keyframes load3 { 60% { transform: scale(1); } 80% { transform: scale(0); } 100% { transform: scale(0); } }
Preview
整體如上所示,如果有看不懂的也歡迎直接回復(fù)...
目前持續(xù)更新中 https://github.com/ajycc20/easy-css-layout ,歡迎大佬們提出意見!?。?/p>
以及,有個(gè)star會更好啊 ( hhhh 逃
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
CSS 實(shí)現(xiàn)各種 Loading 效果附帶解析過程
這篇文章主要介紹了CSS 實(shí)現(xiàn)各種 Loading 效果附帶解析過程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-19- 這篇文章主要介紹了CSS3動畫之DIY Loading動畫的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-12-27
- 這是一款基于css3齒輪loading動畫特效,使用font-awesome字體圖標(biāo)的齒輪圖標(biāo)作為圖案,通過CSS3 animation來制作三個(gè)齒輪的運(yùn)動效果。感興趣的朋友跟隨小編一起看看吧2018-09-27
CSS實(shí)現(xiàn)一個(gè)簡單loading動畫效果
CSS的animation可以做出大多數(shù)的loading效果,今天腳本之家小編給大家?guī)砹嘶贑SS實(shí)現(xiàn)一個(gè)簡單loading動畫效果,非常不錯(cuò),需要的朋友參考下吧2018-04-17- 本篇文章主要介紹了一份純CSS loading效果代碼示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-16
用純CSS實(shí)現(xiàn)餅狀Loading等待圖效果
這篇文章主要介紹了用純CSS實(shí)現(xiàn)餅狀Loading等待圖效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-23使用CSS時(shí)間打點(diǎn)的Loading效果的教程
這篇文章主要介紹了使用CSS時(shí)間打點(diǎn)的Loading效果的教程,分別是基于box-shadow和基于border+background的兩種實(shí)現(xiàn)方法,需要的朋友可以參考下2015-06-08- 這篇文章主要為大家介紹了css實(shí)現(xiàn)葉子形狀loading效果的方法,通過修改border-radius的參數(shù)實(shí)現(xiàn)的該效果,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-01-30
純CSS實(shí)現(xiàn)loading加載中效果(多種展現(xiàn)形式)
現(xiàn)如今網(wǎng)頁越來越趨近于動畫,相信大家平時(shí)瀏覽網(wǎng)頁或多或少都能看到一些動畫效果,今天我們來做一個(gè)有意思的動畫效果,純 css 實(shí)現(xiàn) loading 加載中(多種展現(xiàn)形式),下面2023-02-08