css anminate 加载中三个点点动态出现

期待效果:

核心代码:

css3 anminate方法

css 复制代码
//html
<div>加载中<span id="dot">...</span></div>
 
//css
<style>  
#dot {
    display: inline-block;
    width: 1.5em;
    vertical-align: bottom;
    overflow: hidden;
    animation: dotting 3s infinite step-start;
}
@keyframes dotting{
    0% { width: 0; margin-right: 1.5em; }
    33% { width: .5em; margin-right: 1em; }
    66% { width: 1em; margin-right: .5em; }
    100% { width: 1.5em; margin-right: 0;}
}
</style>

一、代码实操

html代码:

html 复制代码
 <div class="contanier">
          <img
            :src="
              getAssetsFile(
                data.isFinish == 0
                  ? `smartCabin/loadingImg/isLoading_bg.png`
                  : `smartCabin/loadingImg/isErr_bg.png`
              )
            "
          />
          <div class="imgTitle">加载中<span id="dot">...</span></div>
        </div>

css:

css 复制代码
  .contanier {
    width: 50%;
    height: 80%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .imgTitle {
      font-size: calc(100vw * 18 / 1920);
      color: #757575;
      line-height: 21px;
      letter-spacing: 2px;

      #dot {
        display: inline-block;
        width: 1.5em;
        vertical-align: bottom;
        overflow: hidden;
        animation: dotting 0.5s infinite step-start;
      }
      @keyframes dotting {
        0% {
          width: 0;
          margin-right: 1.5em;
        }
        33% {
          width: 0.5em;
          margin-right: 1em;
        }
        66% {
          width: 1em;
          margin-right: 0.5em;
        }
        100% {
          width: 1.5em;
          margin-right: 0;
        }
      }
    }
    .imgTitle2 {
      .imgTitle;
      color: red;
    }

以上就是全部实现代码。。。

以下是理论知识

二、理论知识:

使用简写属性 animation 一次性设置所有动画属性,很方便。

anminate:CSS animation 属性是animation-durationhttps://developer.mozilla.org/zh-CN/docs/Web/CSS/animation-duration详情看MDN

相关推荐
flower_tomb几秒前
对浏览器事件机制的理解
前端·javascript·vue.js
用户45820315317几秒前
使用Trae做一个简单的天狗食日动画效果试试
前端·trae
普通码农3 分钟前
Vue Element Plus X 部署后资源加载失败问题
前端
超人不会飛4 分钟前
仿豆包 H5应用核心模板:用Vue快速复刻大模型对话体验
前端·javascript·vue.js
程序张7 分钟前
Vue3+Vite 现代化前端框架👊打破 Chrome 83 内核限制
前端·javascript·vue.js
拜无忧9 分钟前
【教程】Vue中级转React终极指南-理解Vue和React的差异
前端·vue.js·react.js
web前端12310 分钟前
Android开发四大组件详解
前端
木辰風11 分钟前
idea npm install 很慢(nodejs)
前端·npm·node.js
阿笑带你学前端11 分钟前
Drift数据库开发实战:类型安全的SQLite解决方案
前端·flutter
FE_C_P小麦14 分钟前
Git 常用指令
前端·后端·github