演示

这里页面四周的彩色灯珠是会随着页面调整自动调整位置的。
代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Light Effects</title>
    <style>
        * {
            user-select: none;
            margin: 0;
            padding: 0;
        }
        .bg {
            height: 100vh;
            width: 100vw;
        }
        .bg>img {
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
            height: 100%;
            object-fit: cover;
            padding: 0px;
            position: absolute;
            width: 100%;
        }
        .effects.show {
            opacity: 1;
        }
        .effects {
            position: fixed;
            overflow: hidden;
            height: 100vh;
            width: 100vw;
            left: 0px;
            top: 0px;
            z-index: 700;
            pointer-events: none;
        }
        .light .frame {
            background-image: url("./light.img");
            position: absolute;
            height: 100px;
            background-repeat: repeat-x;
            background-size: contain;
            background-position: center bottom;
        }
        .left.frame {
            top: -133px;
            left: 0px;
            transform: rotate(90deg);
            transform-origin: 0px 100px;
            width: 500%;
        }
        .top.frame {
            top: 0px;
            width: 500%;
            transform: rotate(180deg);
        }
        .right.frame {
            top: 100%;
            left: calc(100% - 100px);
            transform: rotate(-90deg);
            transform-origin: 0px 0px;
            width: 500%;
        }
        .bottom.frame {
            bottom: 0px;
            left: 0px;
            width: 500%;
        }
    </style>
</head>
<body>
    <div class="bg">
        <img src="./R0000937.webp" alt="">
    </div>
    <div class="light effects show">
        <div class="left frame"></div>
        <div class="top frame"></div>
        <div class="right frame"></div>
        <div class="bottom frame"></div>
    </div>
</body>
</html>
上面代码中的 light.img 就是演示中页面四周的彩色灯珠,相关图片可以在下面的例程链接中的 examples/20230806-decoration 例程中找到。
更多例程
更多例程可以参考下面代码仓库:
 https://github.com/NaisuXu/front-end-web-examples



















