html5+css3日食场景

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS3 日食场景</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(to bottom, #1a1a2e, #16213e, #0f3460);
            overflow: hidden;
            font-family: Arial, sans-serif;
        }

        .scene {
            position: relative;
            width: 100%;
            height: 100%;
        }

        .sun {
            position: absolute;
            width: 150px;
            height: 150px;
            background: radial-gradient(circle, #ffde59, #ff8c00);
            border-radius: 50%;
            box-shadow: 0 0 50px #ff8c00, 0 0 100px #ff8c00;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1;
        }

        .moon {
            position: absolute;
            width: 160px;
            height: 160px;
            background: #16213e;
            border-radius: 50%;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 2;
            animation: eclipse 10s linear infinite;
        }

        @keyframes eclipse {
            0% {
                transform: translate(-250%, -50%);
            }
            40% {
                transform: translate(-50%, -50%);
            }
            60% {
                transform: translate(-50%, -50%);
            }
            100% {
                transform: translate(150%, -50%);
            }
        }

        .corona {
            position: absolute;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 0;
            background: radial-gradient(circle, rgba(255,140,0,0.8) 0%, rgba(255,140,0,0) 70%);
            opacity: 0;
            animation: corona 10s linear infinite;
        }

        @keyframes corona {
            35% { opacity: 0; }
            45% { opacity: 1; }
            55% { opacity: 1; }
            65% { opacity: 0; }
        }

        .stars {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        .star {
            position: absolute;
            background-color: white;
            border-radius: 50%;
            animation: twinkle 2s infinite alternate;
        }

        @keyframes twinkle {
            from { opacity: 0.2; }
            to { opacity: 1; }
        }

        .footer {
            position: absolute;
            bottom: 20px;
            width: 100%;
            text-align: center;
            color: white;
            font-size: 14px;
            z-index: 10;
        }

        .footer a {
            color: #ff8c00;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="scene">
        <div class="stars" id="stars"></div>
        <div class="sun"></div>
        <div class="moon"></div>
        <div class="corona"></div>

        <div class="footer">

        </div>
    </div>

    <script>
        // 创建星星
        const starsContainer = document.getElementById('stars');
        const starsCount = 200;

        for (let i = 0; i < starsCount; i++) {
            const star = document.createElement('div');
            star.classList.add('star');

            // 随机大小 (1-3px)
            const size = Math.random() * 2 + 1;
            star.style.width = `${size}px`;
            star.style.height = `${size}px`;

            // 随机位置
            star.style.left = `${Math.random() * 100}%`;
            star.style.top = `${Math.random() * 100}%`;

            // 随机闪烁延迟
            star.style.animationDelay = `${Math.random() * 2}s`;

            starsContainer.appendChild(star);
        }
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值