倒计时动效

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;
  }
}
相关推荐
用户059540174469 小时前
把AI长期记忆测试从手动验证换成pytest,2天揪出11个隐藏Bug
前端·css
a11177611 小时前
唯美花朵风格的黑胶唱片音乐播放器
前端·css·css3
用户2986985301415 小时前
在 PC 上将 HTML 转换为 PDF 的3种有效方法
人工智能·c#·html
布兰妮甜16 小时前
CSS 现代布局终极方案:Grid 完整实战,替代浮动/弹性布局复杂场景
css·grid·实战教程·浮动·web布局
IMPYLH19 小时前
HTML 的 <dialog> 元素
前端·html
JR空位投 李佃贵是20 小时前
如何编写轻量级 CSS 框架
前端·css·tensorflow
寒水馨2 天前
Windows下载、安装 Tailwind CSS-v4.3.3(附安装包tailwindcss-windows-x64.exe)
前端·css·前端开发·tailwind css·utility-first·css 框架·独立 cli
2301_764441332 天前
智慧农业管理平台灵感
开源·html
a1117762 天前
3D 建筑编辑器 Pascal Editor THreeJS 开源
前端·3d·html
思码梁田2 天前
CSS 定位详解:从相对到固定,掌握网页布局的核心
前端·javascript·css