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

相关推荐
猫七先生7 分钟前
在 React 里用 PMTiles 自托管底图
前端
tanghonghanhaoli7 分钟前
【图书翻译】有意义的游戏设计:桌面游戏的方法论与心理学(第1、2章)
前端·游戏·ui
光影少年8 分钟前
react native打包优化、包体积瘦身、离线包/热更新方案
前端·react native·react.js
Cache技术分享11 分钟前
504. Java 反射 - 创建一个简单的依赖注入框架
前端·后端
_codeOH20 分钟前
# 手把手复刻 DeepSeek 官网效果:玻璃拟态 + WebGL 流体 + Spring 动画,一篇讲透
前端
名字还没想好☜22 分钟前
Next.js 用 cookies()/headers() 读请求信息:动态渲染触发、缓存失效与在 Server Action 里读写 cookie
前端·javascript·缓存·react·next.js·app router
今日无bug40 分钟前
从「拿来主义」到「亲手造轮子」:2 种 MCP 文件服务器写法对比
前端·node.js·mcp
xcyxiner41 分钟前
flutter 运行到模拟器上
android·前端·flutter
用户9210802628641 分钟前
从 COT 到 ThoughtChain:AI 应用为什么需要展示“思考过程”
前端
天真小巫42 分钟前
2026.8.23总结
前端·html