倒计时动效

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;
  }
}
相关推荐
SamHou03 小时前
手把手 CSS 盒子模型——从零开始的奶奶级 Web 开发教程2
前端·css·web
kooboo china.5 小时前
Tailwind CSS 实战:基于 Kooboo 构建 AI 对话框页面(八):异步处理逻辑详解
前端·css·人工智能·编辑器·html·交互
Allen Bright6 小时前
【HTML-16】深入理解HTML中的块元素与行内元素
前端·html
菜鸟小九7 小时前
html、css(javaweb第一天)
前端·css·html
这是个栗子9 小时前
HTML(一)
javascript·ajax·css3·html5
Amctwd9 小时前
【HTML】HTML 与 CSS 基础教程
前端·css·html
iam10 小时前
使用 CSS 实现 iOS 26 液态玻璃(Frosted Glass)效果
css
火车叼位10 小时前
理解 CSS Layer样式管理
css
尽欢i11 小时前
HTML iframe 详细解读
html
令狐寻欢11 小时前
HTML中 的 meta 标签常用属性及其作用
前端·html