倒计时动效

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;
  }
}
相关推荐
志尊宝2 天前
Vue3 零基础每日笔记(055):组件里正确使用 store——storeToRefs 解构与 $patch 批量修改
笔记·vue·html·前端开发·软件开发
吴声子夜歌2 天前
HTML——看似普通的元素的背后(<a>标签)
html
IMPYLH2 天前
HTML 的 <style> 元素
前端·html
刃神太酷啦2 天前
前端入门第一课:HTML 基础语法 + 常用标签 + 实战全解
服务器·c语言·前端·javascript·css·c++·html
IMPYLH2 天前
HTML 的 <strong> 元素
前端·html
开开心心就好2 天前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
扶苏10023 天前
CSS 图标换色指南:用 brightness / invert / mask 把任意图片改成想要的颜色
css
我命由我123453 天前
CSS - CSS 媒体查询 orientation
前端·javascript·css·html·css3·html5·js
咩咩啃树皮3 天前
ES6 Set 核心特点 + 最简数组去重
前端·javascript·html
zhanghaha13143 天前
HTML系列教程:18_HTML / CSS 颜色零基础详解
css·html·tensorflow