最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js實(shí)現(xiàn)酷炫倒計(jì)時(shí)動(dòng)畫

 更新時(shí)間:2022年07月13日 11:10:41   作者:#麻辣小龍蝦#  
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)酷炫倒計(jì)時(shí)動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js實(shí)現(xiàn)酷炫倒計(jì)時(shí)動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下

前段時(shí)間和朋友去音樂餐廳吃飯,中間有個(gè)活動(dòng),然后看到他們軟件公眾號(hào)H5有個(gè)活動(dòng)開始的倒計(jì)時(shí)的動(dòng)畫效果,于是想了下實(shí)現(xiàn)思路。

<!DOCTYPE html>
<html>
<head>
? ? <meta charset="utf-8" />
? ? <title>js實(shí)現(xiàn)酷炫倒計(jì)時(shí)動(dòng)畫效果</title>
? ? <style>
? ? ? *{margin:0;padding:0;}
? ? ? body{width:100%;height:100%;overflow:hidden;}
? ? ? .box{width:1000px;height:700px;margin:100px auto;}
? ? ? .btn{width:100px;height:100px;margin:50px auto 0;font-size:16px;color:#fff;text-align:center;line-height:100px;border-radius:100px;background:#3385ff;}
? ? ? .btn:hover{box-shadow: 0 0 10px #77aeff;cursor:pointer;}
? ? ? h1{font-size:300px;color:red;text-align:center;}
? ? ? h1.active{animation:count .5s;}
? ? ? @keyframes count {
? ? ? ? from {
? ? ? ? ? transform: scale(.1);
? ? ? ? ? opacity: 1;
? ? ? ? }
? ? ? ? to {
? ? ? ? ? transform: scale(3.5);
? ? ? ? ? opacity: 0;
? ? ? ? ? display:none;
? ? ? ? }
? ? ? }
? ? </style>
</head>
<body>
? <div class="btn">倒計(jì)時(shí)</div>
? <div class="box">
? ? <h1 style="display:none;">10</h1>
? </div>
</body>
<script>
? let NUMBER = 1;
? let COUNT = 10;
? let COLORS = ['#8c00ff', '#006bff', '#4fff00', '#ffb800', '#ff0000'];
? let timer = null;
? function $(str) {
? ? return document.querySelector(str);
? }
? function actionNum () {
? ? let h1 = $('h1');
? ? $('h1').style.display = 'block';
? ? timer = setInterval(() => {
? ? ? COUNT--;
? ? ? NUMBER++;
? ? ? if (COUNT >= 0) {
? ? ? ? h1.classList.remove('active');
? ? ? ? setTimeout(() => {
? ? ? ? ? let num = Math.floor(Math.random()*5);
? ? ? ? ? h1.innerText = COUNT;
? ? ? ? ? h1.style.color = COLORS[num];
? ? ? ? ? h1.classList.add('active');
? ? ? ? }, 100);
? ? ? } else {
? ? ? ? clearInterval(timer);
? ? ? }
? ? }, 1000);
? }
? $('.btn').onclick = function () {
? ? if (COUNT < 0) {
? ? ? COUNT = 11;
? ? }
? ? actionNum();
? };
</script>
</html>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

乐陵市| 临颍县| 浠水县| 东山县| 阜新| 保康县| 健康| 安达市| 盐亭县| 定安县| 吉木萨尔县| 兴宁市| 托克逊县| 方山县| 凌源市| 永清县| 武乡县| 库伦旗| 松桃| 临沧市| 洛南县| 石景山区| 绍兴县| 榆树市| 合作市| 旬阳县| 永善县| 平定县| 涪陵区| 隆回县| 四平市| 永州市| 木里| 当阳市| 宕昌县| 乌拉特后旗| 吐鲁番市| 潮安县| 中西区| 扎鲁特旗| 团风县|