倒计时动效

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;
  }
}
相关推荐
念念不忘 必有回响12 小时前
前端判断文本是否溢出:单行与多行场景的完整解析
前端·javascript·css·vue.js
@菜菜_达13 小时前
CSS是什么?
前端·css
Amumu1213813 小时前
CSS基础选择器
前端·css
星火开发设计15 小时前
类模板:实现通用数据结构的基础
java·开发语言·数据结构·c++·html·知识
陆枫Larry17 小时前
CSS 踩坑笔记:为什么列表底部的 margin-bottom 总是“失效”?
css
陆枫Larry17 小时前
深入浅出:CSS 中的“隐形结界”——BFC 详解
前端·css
coding随想19 小时前
深入Modernizr源码:揭秘CSS伪类检测的底层逻辑
前端·css
程序员林北北19 小时前
【前端进阶之旅】3 道前端超难面试题深度解析(2026 版)|附完整代码 + 实战场景
前端·javascript·css3·html5
卷卷的小趴菜学编程19 小时前
项目篇----仿tcmalloc的内存池设计(内存回收)
前端·后端·html·tcmalloc·内存池
拔刀能留住落樱吗、20 小时前
代码诊疗室——疑难Bug破解战
前端·html