javascript - 小demo:請教怎么做出類似于水滴不斷擴(kuò)張的效果?
問題描述
<style> #drop{width:300px;height:300px;border-radius:300px;border:1px solid #000;margin:180px auto 0; }</style> <p id='drop'></p>drop.timer = setInterval(function(){drop.style.cssText = `transition:1s;transform:scale(1.4);opacity:0;transform-origin: 150px 150px; `; },500);
現(xiàn)在我能做到的只是完成一次。但是我想要一直往復(fù)循環(huán)這個過程,從小到大,從清晰到模糊,然后下一次再重復(fù)這個步驟,一直不停的循環(huán)。有沒有好的實(shí)現(xiàn)思路,請教大家!謝謝!
問題解答
回答1:用CSS animation
#drop { width: 300px; height: 300px; border-radius: 300px; border: 1px solid #000; margin: 180px auto 0; transition: 1s; animation: 1s drop infinite; } @keyframes drop { 0% { transform: scale(1); opacity: 1; }100% { transform: scale(1.4); opacity: 0; } }
<p id='drop'></p>
JS什么的都不需要了
相關(guān)文章:
1. 在mac下出現(xiàn)了兩個docker環(huán)境2. css3 - css怎么實(shí)現(xiàn)圖片環(huán)繞的效果3. android - 用textview顯示html時(shí)如何寫imagegetter獲取網(wǎng)絡(luò)圖片4. javascript - 原生canvas中如何獲取到觸摸事件的canvas內(nèi)坐標(biāo)?5. css - 定位為absolute的父元素中的子元素 如何設(shè)置在父元素的下面?6. JavaScript事件7. javascript - jquery hide()方法無效8. 網(wǎng)頁爬蟲 - 用Python3的requests庫模擬登陸B(tài)ilibili總是提示驗(yàn)證碼錯誤怎么辦?9. 注冊賬戶文字不能左右分離10. html - vue項(xiàng)目中用到了elementUI問題
