使用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>
相关推荐
探码科技30 分钟前
AI知识管理软件推荐:九大解决方案与企业应用
前端·ruby
编程小黑马32 分钟前
解决flutter 在控制器如controller 无法直接访问私有类方法的问题
前端
unfetteredman42 分钟前
Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found
前端·javascript·vite
云存储小精灵1 小时前
Dify x 腾讯云 COS MCP:自然语言解锁智能数据处理,零代码构建 AI 新世界
前端·开源
山间板栗1 小时前
微信小程序环境变量设置方案
前端
电商API大数据接口开发Cris1 小时前
Java Spring Boot 集成淘宝 SDK:实现稳定可靠的商品信息查询服务
前端·数据挖掘·api
pepedd8641 小时前
LangChain:大模型开发框架的全方位解析与实践
前端·llm·trae
HANK1 小时前
KLineChart 绘制教程
前端·vue.js
Jerry2 小时前
Compose 利用工具加快开发速度
前端
前端小张同学2 小时前
前端行情好起来了,但是我依然没拿到offer
前端