使用css实现动态loading

效果图

关键样式 - 遮罩mask

www.w3school.com.cn/css/css3_ma...

图片素材

【注】需要透明底色的文字图片

完整代码

html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>loading</title>
    <style lang="scss" scoped>
        * {
            padding: 0;
            margin: 0;
        }

        .a-loading {
            width: 100vw;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .content {
            position: absolute;
            padding: 0 20px;
            border-radius: 20px;
            background-color: #dad8d554;

        }

        .content-loading {
            max-width: 420px;
            min-width: 300px;
            width: 100%;
            height: 90px;
            background: linear-gradient(to right, #ffffff, #d94c4c);
            background-size: 200%;
            animation: translationX 2s linear infinite;
            /* mask-size: 100%; */
            mask-repeat: no-repeat;
            mask-position: center;
            mask-image: url("/images/loading1.png");
        }

        @keyframes translationX {
            0% {
                background-position: 200% 200%;
            }

            100% {
                background-position: 0 0;
            }
        }
    </style>
</head>

<body>
    <div class="a-loading">
        <div class="content">
            <div class="content-loading"> </div>
        </div>
    </div>
</body>

</html>
相关推荐
Mr Xu_2 分钟前
【Vue3 + ECharts 实战】正确使用 showLoading、resize 与 dispose 避免内存泄漏
前端·信息可视化·vue·echarts
0思必得09 分钟前
[Web自动化] Selenium设置相关执行文件路径
前端·爬虫·python·selenium·自动化
雯0609~19 分钟前
hiprint:实现项目部署与打印1-官网提供普通html版本
前端·html
不绝1911 小时前
UGUI——进阶篇
前端
Exquisite.1 小时前
企业高性能web服务器(4)
运维·服务器·前端·网络·mysql
2501_944525542 小时前
Flutter for OpenHarmony 个人理财管理App实战 - 账户详情页面
android·java·开发语言·前端·javascript·flutter
2601_949857432 小时前
Flutter for OpenHarmony Web开发助手App实战:快捷键参考
前端·flutter
wangdaoyin20102 小时前
若依vue2前后端分离集成flowable
开发语言·前端·javascript
心柠3 小时前
vue3相关知识总结
前端·javascript·vue.js
Amumu121383 小时前
Vue Router(二)
java·前端