首頁 > web前端 > js教程 > 使用 JavaScript 程式碼的霓虹燈隨機形狀產生器在 Instagram 上關注我們:https://www.instagram.com/webstreet_code/

使用 JavaScript 程式碼的霓虹燈隨機形狀產生器在 Instagram 上關注我們:https://www.instagram.com/webstreet_code/

DDD
發布: 2024-12-03 06:22:13
原創
840 人瀏覽過

Neon Random Shape Generator using javascript code follow us on instagram: https://www.instagram.com/webstreet_code/

https://www.instagram.com/webstreet_code/

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Random Shape & Color Generator</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      background: radial-gradient(circle, #1e1e1e, #2d2d2d, #3b3b3b, #444444);
      cursor: pointer;
    }

    .shape {
      position: absolute;
      transform: translate(-50%, -50%);
      animation: popIn 0.6s ease;
      filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.7));
    }

    @keyframes popIn {
      0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
      }
      100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
      }
    }

    @keyframes neonBackground {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }

  </style>
</head>
<body>

  <script>
    document.body.addEventListener('click', function (e) {
      const shape = document.createElement('div');
      const size = Math.random() * 120 + 50; // Random size between 50px and 170px
      const colors = [
        '#FF007C', '#00F5D4', '#FAFF00', '#FF5D73', '#08F7FE', 
        '#9B5DE5', '#F15BB5', '#FEE440', '#00BBF9', '#00F5D4'
      ];
      const randomColor = colors[Math.floor(Math.random() * colors.length)];
      const shapes = ['50%', '0%', 'polygon(50% 0%, 0% 100%, 100% 100%)']; // Circle, Square, Triangle

      shape.style.width = `${size}px`;
      shape.style.height = `${size}px`;
      shape.style.background = `linear-gradient(145deg, ${randomColor}, #000)`;
      shape.style.borderRadius = shapes[Math.floor(Math.random() * shapes.length)];
      shape.style.left = `${e.clientX}px`;
      shape.style.top = `${e.clientY}px`;
      shape.style.boxShadow = `0 0 20px ${randomColor}, 0 0 40px ${randomColor}, 0 0 80px ${randomColor}`;
      shape.classList.add('shape');

      document.body.appendChild(shape);

      setTimeout(() => {
        shape.style.transition = 'transform 0.5s ease, opacity 0.5s ease';
        shape.style.transform = 'translate(-50%, -50%) scale(0)';
        shape.style.opacity = '0';
      }, 1000);

      setTimeout(() => {
        shape.remove();
      }, 1500);
    });
  </script>

</body>
</html>

登入後複製

以上是使用 JavaScript 程式碼的霓虹燈隨機形狀產生器在 Instagram 上關注我們:https://www.instagram.com/webstreet_code/的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:dev.to
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板