微信小程序前端扫码动画效果绿色光效移动,四角椭圆

大家好,我的开源项目PakePlus可以将网页/Vue/React项目打包为桌面/手机应用并且小于5M只需几分钟,官网地址:pakeplus.com

纯html和css实现的效果,中间的绿色会向下移动,放在微信小程序中也可以生效,全部html代码如下:

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>扫码扫描线效果</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }

            body {
                width: 100vw;
                height: 100vh;
                background: #000;
                overflow: hidden;
            }

            /* 遮罩层 */
            .scan-mask {
                position: fixed;
                inset: 0;
                background: rgba(0, 0, 0, 0.75);
                display: flex;
                justify-content: center;
                align-items: center;
            }

            /* 扫码框 */
            .scan-box {
                position: relative;
                width: 280px;
                height: 280px;
                box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
            }

            /* 四个圆角 */
            .corner {
                position: absolute;
                width: 44px;
                height: 44px;
                border: 3px solid #fff;
            }

            .tl {
                top: 0;
                left: 0;
                border-right: none;
                border-bottom: none;
                border-radius: 16px 0 0 0;
            }

            .tr {
                top: 0;
                right: 0;
                border-left: none;
                border-bottom: none;
                border-radius: 0 16px 0 0;
            }

            .bl {
                bottom: 0;
                left: 0;
                border-right: none;
                border-top: none;
                border-radius: 0 0 0 16px;
            }

            .br {
                bottom: 0;
                right: 0;
                border-left: none;
                border-top: none;
                border-radius: 0 0 16px 0;
            }

            /* 扫描线主体 */
            .scan-line {
                position: absolute;
                left: 0;
                right: 0;
                height: 2px; /* 下边平直 */
                animation: scan 2.4s linear infinite;
            }

            /* 上方拱形发散光(核心) */
            .scan-line::before {
                content: '';
                position: absolute;
                left: -35px;
                right: -35px;
                bottom: 100%;
                height: 90px;

                background: radial-gradient(
                    ellipse at center bottom,
                    rgba(39, 243, 184, 0.45) 0%,
                    rgba(39, 243, 184, 0.25) 35%,
                    rgba(39, 243, 184, 0.12) 55%,
                    rgba(39, 243, 184, 0.05) 70%,
                    rgba(39, 243, 184, 0) 85%
                );

                filter: blur(1.5px);
                pointer-events: none;
            }

            /* 横向亮度集中 */
            .scan-line::after {
                content: '';
                position: absolute;
                inset: 0;
                opacity: 0.9;
            }

            @keyframes scan {
                0% {
                    top: 0;
                }
                100% {
                    top: 100%;
                }
            }

            /* 底部提示 */
            .tip {
                position: fixed;
                bottom: 80px;
                width: 100%;
                text-align: center;
                color: rgba(255, 255, 255, 0.85);
                font-size: 14px;
                letter-spacing: 1px;
            }
        </style>
    </head>

    <body>
        <div class="scan-mask">
            <div class="scan-box">
                <i class="corner tl"></i>
                <i class="corner tr"></i>
                <i class="corner bl"></i>
                <i class="corner br"></i>

                <div class="scan-line"></div>
            </div>
        </div>

        <div class="tip">请将二维码放入框内</div>
    </body>
</html>
相关推荐
JustHappy2 小时前
古法编程秘籍(七):互联网到底是什么?把两台电脑怎么说话搞懂就够了
前端·后端·网络协议
snow@li2 小时前
SEO-文章标题:写文章时候,分类+主标题+大纲+解释 作为标题 / 不点进去也知道全文覆盖什么 / 标题即架构
前端
kyriewen3 小时前
Git Commit 前自动修复代码风格?配置 Husky + lint-staged,从此 CR 只聊逻辑
前端·git·面试
小和尚同志3 小时前
AI 自动化测试探索(一):Playwright MCP
前端·人工智能·aigc
老马识途2.03 小时前
在AI的帮助下理解spring的启动过程
java·前端·spring
徐小夕4 小时前
Loop Engineering 深度解析与实战指南(全网最全)
前端·算法·github
运筹vivo@4 小时前
Python ContextVar 底层机制与内存模型拆解
前端·数据库·python
#麻辣小龙虾#5 小时前
基于vue3.0开发一款【固废与废气运维管理系统】(支持源码)
前端·vue.js·vue3
Cosolar5 小时前
Docsify零构建文档站完全指南:从快速搭建到企业级部署
前端·开源·github
weixin_471383036 小时前
Taro-02-页面路由
前端·taro