当前位置: 首页 > news >正文

使用 HTML CSS 和 JAVASCRIPT 的黑洞动画

使用 HTML CSS 和 JAVASCRIPT 的黑洞动画

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Black Hole Animation</title>
  <style>
    body {
      margin: 0;
      overflow: hidden;
      background: radial-gradient(ellipse at center, black, #1a1a1a);
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .black-hole-container {
      position: relative;
      width: 300px;
      height: 300px;
    }

    .black-hole {
      position: absolute;
      bottom: 20px;
      left: 50%;
      width: 200px;
      height: 200px;
      background: black;
      border-radius: 50%;
      border: 10px solid transparent;
      /* background-image: conic-gradient(pink 0% 33%, purple 33% 66%, blue 66% 100%); */
      box-shadow: 
        0 0 20px 5px pink,
        0 0 40px 10px purple,
        0 0 60px 15px blue;
      animation: neon-glow 3s infinite ease-in-out;
      transform: translateX(-50%);
    }

    .purple-shadow {
      position: absolute;
      top: 30px;
      left: 50%;
      width: 450px;
      height: 450px;
      background: radial-gradient(circle, rgba(128, 0, 128, 0.2), transparent 70%);
      border-radius: 50%;
      transform: translate(-50%);
      animation: wave-color-motion 5s infinite ease-in-out;
    }

    .stars {
      position: absolute;
      width: 100%;
      height: 100%;
      z-index: -1;
    }

    .star {
      position: absolute;
      width: 4px;
      height: 4px;
      background: purple;
      border-radius: 50%;
      animation: twinkle 3s infinite ease-in-out;
    }

    /* Animations */
    @keyframes neon-glow {
      0%, 100% {
        box-shadow: 
          0 0 20px 5px pink,
          0 0 40px 10px purple,
          0 0 60px 15px blue;
      }
      50% {
        box-shadow: 
          0 0 30px 10px pink,
          0 0 50px 15px purple,
          0 0 70px 20px blue;
      }
    }

    @keyframes wave-color-motion {
      0% {
        transform: translate(-50%) scale(1);
        background: radial-gradient(circle, rgba(59, 3, 59, 0.2), transparent 70%);
      }
      25% {
        transform: translate(-50%) scale(1.1);
        background: radial-gradient(circle, rgba(170, 0, 170, 0.4), transparent 70%);
      }
      50% {
        transform: translate(-50%) scale(1.2);
        background: radial-gradient(circle, rgba(200, 0, 200, 0.6), transparent 70%);
      }
      75% {
        transform: translate(-50%) scale(1.1);
        background: radial-gradient(circle, rgba(170, 0, 170, 0.4), transparent 70%);
      }
      100% {
        transform: translate(-50%) scale(1);
        background: radial-gradient(circle, rgba(128, 0, 128, 0.2), transparent 70%);
      }
    }

    @keyframes twinkle {
      0%, 100% {
        opacity: 1;
      }
      50% {
        opacity: 0.2;
      }
    }
  </style>
</head>
<body>
  <div class="black-hole-container">
    <div class="purple-shadow"></div>
    <div class="black-hole"></div>
  </div>
  <div class="stars"></div>

  <script>
    const starsContainer = document.querySelector('.stars');

    // Generate random stars
    for (let i = 0; i < 200; i++) {
      const star = document.createElement('div');
      star.classList.add('star');
      star.style.left = `${Math.random() * 100}vw`;
      star.style.top = `${Math.random() * 100}vh`;
      star.style.animationDelay = `${Math.random() * 5}s`;
      starsContainer.appendChild(star);
    }
  </script>
</body>
</html>

相关文章:

  • 解决IDEA报错:java 找不到符号
  • 鸿蒙应用开发者基础
  • AI前端开发:驶向国际化职业发展快车道
  • 09 解决方案 - 开源机器人+具身智能+AI
  • 2010年上半年软件设计师考试上午真题的知识点整理(附真题及答案解析)
  • Ubuntu 下 nginx-1.24.0 源码分析 - ngx_localtime 函数
  • 3D数字化技术:重塑“人货场”,开启营销新纪元
  • 机器学习周报-文献阅读
  • 刷SQL总结
  • [matlab优化算法-18期】基于遗传算法的模糊PID控制优化
  • 2025-alibaba-分布式事务组件-Seata
  • 神经网络新手入门(2)基础认知:神经网络发展简史
  • Kubernetes控制平面组件:etcd常用配置参数
  • 升级进行中 您的邮箱正在作为Outlook 2013升级的一部分优化
  • 基于Yolo11的无人机小目标检测系统的设计与性能优化改进项目实现
  • 利用二分法+布尔盲注、时间盲注进行sql注入
  • CNN|ResNet-50
  • java基础——IO流
  • 对界面简单易用封装SDK
  • 动态多线程算法概述
  • 外交部:对伊朗拉贾伊港口爆炸事件遇难者表示深切哀悼
  • 从 “沪惠保” 到 “沪骑保”看普惠保险的 “上海样式”
  • 别让心脏“饿肚子”,心肌缺血全解析
  • 仅退款正式成历史?仅退款究竟该不该有?
  • 一年吸引30多万人次打卡,江苏这个渔村是怎么做到的?
  • “归雁经济”能带来什么?川大商学院调研团队深入乡村与返乡青年人才交流