倒计时动效

1. 效果

2. html

html 复制代码
<div class="count">
  <span>3</span>
  <span>2</span>
  <span>1</span>
</div>

3. css

css 复制代码
body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.count {
  position: relative;
  width: 180px;
  height: 180px;
  font-family: Consolas, Monaco, monospace;
  font-size: 100px;
  border: 5px solid #333333;
  border-radius: 50%;
  overflow: hidden;
}

.count span {
  display: block;
  width: 100%;
  height: 180px;
  line-height: 180px;
  text-align: center;
  animation: count 5s steps(5, end) forwards, shark 1s .8s 5;
}

.count::after {
  content: 'Go!';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  font-size: 70px !important;
  animation: go .5s 3s forwards;
}

@keyframes count {
  to {
    transform: translateY(calc(-5 * 180px));
  }
}

@keyframes shark {
  0% {
    opacity: 1;
  }

  20% {
    opacity: 0;
    font-size: 40px;
  }
}

@keyframes go {
  to {
    font-size: 70px;
    opacity: 1;
  }
}
相关推荐
滔滔不绝tao1 小时前
自动化测试常用函数
前端·css·html5
哆木4 小时前
部署在线GBA游戏,并通过docker安装启动
游戏·html·gba
丶重明6 小时前
【2024】前端学习笔记3-外部链接-内部链接-锚点链接
html
小ᶻᶻᶻ8 小时前
HTML 和 CSS
html
软件技术NINI8 小时前
html知识点框架
前端·html
autumn86810 小时前
什么是css?
css
Estrella1610 小时前
经典 web 页面排版:三栏布局
前端·css·面试
世俗ˊ11 小时前
CSS入门笔记
前端·css·笔记
6230_11 小时前
git使用“保姆级”教程1——简介及配置项设置
前端·git·学习·html·web3·学习方法·改行学it
加勒比海涛12 小时前
HTML 揭秘:HTML 编码快速入门
前端·html