倒计时动效

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;
  }
}
相关推荐
七牛开发者1 天前
HTML is the new Markdown:来自 Claude Code 团队的实践
前端·人工智能·语言模型·html
@大迁世界1 天前
43.HTML 事件处理和 React 事件处理有什么区别?
前端·javascript·react.js·html·ecmascript
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_38:(DocumentFragment 文档片段接口详解)
前端·javascript·ui·html·音视频
@大迁世界1 天前
41.ShadCN 是什么?它如何和 Tailwind CSS 集成,从而更容易构建可访问且可自定义的 React 组件?
前端·javascript·css·react.js·前端框架
容智信息1 天前
AI Agent(智能体)的输出格式应该从 Markdown 转向 HTML吗?
前端·人工智能·rust·编辑器·html·prompt
梨子同志1 天前
CSS Grid
前端·css
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_40:(DOMImplementation 接口完全解析)
前端·ui·html·媒体
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_39:(DOMException 异常接口完全解析)
前端·javascript·html·媒体
我命由我123451 天前
Dart - Dart SDK、Hello World 案例、变量声明、常量声明、常量 final、字符串类型
前端·flutter·前端框架·html·web·dart·web app