HTML 会动的蜡烛。




html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Candle Effect</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #1a1a1a;
        }

        .candle {
            position: relative;
            width: 30px;
            height: 100px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
        }

        .flame {
            position: absolute;
            top: -20px;
            left: 50%;
            transform: translateX(-50%);
            width: 15px;
            height: 30px;
            background-color: #ffcc00;
            border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
            animation: flicker 0.1s infinite alternate;
        }

        .flame::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 10px;
            height: 10px;
            background-color: #ff6600;
            border-radius: 50%;
            opacity: 0.5;
        }

        @keyframes flicker {
            0% {
                transform: translateX(-50%) scale(1);
            }
            100% {
                transform: translateX(-50%) scale(1.1);
            }
        }

        .glow {
            position: absolute;
            top: -30px;
            left: 50%;
            transform: translateX(-50%);
            width: 40px;
            height: 40px;
            background-color: rgba(255, 204, 0, 0.2);
            border-radius: 50%;
            animation: glow 1s infinite alternate;
        }

        @keyframes glow {
            0% {
                box-shadow: 0 0 20px 10px rgba(255, 204, 0, 0.2);
            }
            100% {
                box-shadow: 0 0 30px 15px rgba(255, 204, 0, 0.4);
            }
        }
    </style>
</head>
<body>
    <div class="candle">
        <div class="flame"></div>
        <div class="glow"></div>
    </div>
</body>
</html>
相关推荐
stark张宇24 分钟前
Web - CSS3浮动定位与背景样式
前端·css·css3
tekin1 小时前
Vue.js组件开发
前端·javascript·vue.js·vue·vue组件·vue.js组件开发
大雄野比1 小时前
Vue3.5常用特性整理
前端·javascript·vue.js
m0_528723811 小时前
如何利用i18n实现国际化
前端·javascript·vue.js
一个处女座的程序猿O(∩_∩)O1 小时前
React+AI 技术栈(2025 版)
前端·人工智能·react.js
恰小面包1 小时前
react使用DatePicker日期选择器
前端·react.js·前端框架
engchina1 小时前
React中key值的正确使用指南:为什么需要它以及如何选择
前端·react.js·前端框架
engchina1 小时前
React组件开发技巧:如何优雅地传递Props?
前端·javascript·react.js
偷光1 小时前
Vue3 对比 React18—不只是技术选择
前端·javascript·react.js
Lsland..2 小时前
Spring Boot 配置文件详解:YAML vs Properties
java·前端·spring boot