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

相关推荐
你的人类朋友36 分钟前
说说git的变基
前端·git·后端
姑苏洛言39 分钟前
网页作品惊艳亮相!这个浪浪山小妖怪网站太治愈了!
前端
字节逆旅1 小时前
nvm 安装pnpm的异常解决
前端·npm
Jerry1 小时前
Compose 从 View 系统迁移
前端
GIS之路1 小时前
2025年 两院院士 增选有效候选人名单公布
前端
四岁半儿1 小时前
vue,H5车牌弹框定制键盘包括新能源车牌
前端·vue.js
烛阴2 小时前
告别繁琐的类型注解:TypeScript 类型推断完全指南
前端·javascript·typescript
gnip2 小时前
工程项目中.env 文件原理
前端·javascript
JefferyXZF2 小时前
Next.js Server Actions 详解: 无缝衔接前后端的革命性技术(八)
前端·全栈·next.js
芜青3 小时前
HTML+CSS:浮动详解
前端·css·html