首页 > web前端 > js教程 > 正文

✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 HTML CSS 和 JAVASCRIPT

DDD
发布: 2024-12-10 22:42:01
转载
420人浏览过

✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 html css 和 javascript

无涯·问知
无涯·问知

无涯·问知,是一款基于星环大模型底座,结合个人知识库、企业知识库、法律法规、财经等多种知识源的企业级垂直领域问答产品

无涯·问知 153
查看详情 无涯·问知
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Disco Bulb Animation</title>
  <style>
    body {
      margin: 0;
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
      background: linear-gradient(45deg, #000000, #111111);
      font-family: Arial, sans-serif;
    }

    .container {
      display: flex;
      gap: 200px;
    }

    .wall {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      height: 300px;
      padding: 15px;
      border-radius: 10px;
      background: rgba(96, 95, 95, 0.281);
      backdrop-filter: blur(10px);
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    }

    .bulb {
      width: 60px;
      height: 60px;
      background: rgba(255, 255, 255, 0.1);
      border: 2px solid rgba(255, 255, 255, 0.2);
      border-radius: 50%;
      backdrop-filter: blur(10px);
      box-shadow: 0 0 5px rgba(255, 255, 255, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.1);
      transition: box-shadow 0.3s, background-color 0.3s;
    }

    .bulb.glow {
      animation: disco 0.2s infinite alternate;
    }

    @keyframes disco {
      0% {
        background-color: rgba(255, 0, 128, 0.8);
        box-shadow: 0 0 40px 40px rgba(255, 0, 128, 0.8);
      }
      25% {
        background-color: rgba(0, 255, 128, 0.8);
        box-shadow: 0 0 30px 10px rgba(0, 255, 128, 0.8);
      }
      50% {
        background-color: rgba(0, 128, 255, 0.8);
        box-shadow: 0 0 30px 10px rgba(0, 128, 255, 0.8);
      }
      75% {
        background-color: rgba(255, 255, 0, 0.8);
        box-shadow: 0 0 30px 10px rgba(255, 255, 0, 0.8);
      }
      100% {
        background-color: rgba(255, 128, 0, 0.8);
        box-shadow: 0 0 30px 10px rgba(255, 128, 0, 0.8);
      }
    }

    .start-button {
      position: absolute;
      bottom: 50px;
      padding: 15px 30px;
      background: #ff5722;
      color: white;
      border: none;
      border-radius: 10px;
      cursor: pointer;
      font-size: 18px;
      font-weight: bold;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
      transition: background 0.3s;
    }

    .start-button:hover {
      background: #ff784e;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="wall">
      <div class="bulb" id="left-bulb-1"></div>
      <div class="bulb" id="left-bulb-2"></div>
      <div class="bulb" id="left-bulb-3"></div>
    </div>
    <div class="wall">
      <div class="bulb" id="right-bulb-1"></div>
      <div class="bulb" id="right-bulb-2"></div>
      <div class="bulb" id="right-bulb-3"></div>
    </div>
  </div>
  <button class="start-button" onclick="startDisco()">
    Start</button>

  <script>
    async function startDisco() {
      const leftBulbs = [
        document.getElementById("left-bulb-1"),
        document.getElementById("left-bulb-2"),
        document.getElementById("left-bulb-3"),
      ];
      const rightBulbs = [
        document.getElementById("right-bulb-1"),
        document.getElementById("right-bulb-2"),
        document.getElementById("right-bulb-3"),
      ];
      // Function to glow a bulb for 3 seconds
      async function glowBulb(bulb) {
        bulb.classList.add("glow");
        await new Promise((resolve) => 
        setTimeout(resolve, 3000));
        bulb.classList.remove("glow");
      }
      // Glow bulbs on the left wall
      for (let bulb of leftBulbs) {
        await glowBulb(bulb);
      }
      // Glow bulbs on the right wall
      for (let bulb of rightBulbs) {
        await glowBulb(bulb);
      }
    }
  </script>
</body>
</html>

登录后复制

以上就是✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 HTML CSS 和 JAVASCRIPT的详细内容,更多请关注php中文网其它相关文章!

相关标签:
HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:dev.to网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号