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

相关推荐
Можно6 分钟前
深入理解 ES6 Proxy:与 Object.defineProperty 的全面对比
前端·javascript·vue.js
Birdy_x20 分钟前
接口自动化项目实战(1):requests请求封装
开发语言·前端·python
天天向上10242 小时前
vue el-table实现拖拽排序
前端·javascript·vue.js
柳杉3 小时前
Three.js × Blender:从建模到 Web 3D 的完整工作流深度解析
前端·javascript·数据可视化
reembarkation4 小时前
vue3中使用howler播放音频列表
前端·vue.js·音视频
手握风云-4 小时前
基于 Java 的网页聊天室(三)
服务器·前端·数据库
weixin199701080164 小时前
《识货商品详情页前端性能优化实战》
前端·性能优化
Forever7_4 小时前
重磅!Vue3 手势工具正式发布!免费使用!
前端·前端框架·前端工程化
用户806138166594 小时前
发布为一个 npm 包
前端·javascript
树上有只程序猿4 小时前
低代码何时能出个“秦始皇”一统天下?我是真学不动啦!
前端·后端·低代码