整合 particle.js 和 bootstrap

Integrate particle.js and bootstrap

尝试将 particles.js 效果添加到我的主要 header,但它似乎不起作用,我也找不到原因。
尝试添加 class/id particles-js 但没有成功。 这是我的 fiddle:https://jsfiddle.net/thek1d21/dtj0Lz3w/21/ 几乎每次我都设法自己找到解决方案,但这次不是。

谢谢。

我的代码:

<!DOCTYPE html>
<html lang="en">

  <head>

  </head>

  <body>
    <!---Page Header-->
    <div id="particles-js">
      <div class="section section-shaped light-blue">
        <div class="page-header">
          <div class="row">
          </div>
        </div>
      </div>
    </div>
  </body>

</html>

CSS:

.section {
  position: relative;
  overflow: hidden;
}

.section-shaped {
  position: relative;
  overflow: hidden;
}

.page-header {
  min-height: 75vh;
  max-height: 999px;
  padding: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.light-blue {
  background-color: rgba(28, 206, 234, 0.82);
  background-image: linear-gradient(-45deg, rgba(147, 26, 222, 0.83) 0%, rgba(28, 206, 234, 0.82) 100%);
}



#particles-js {
  height: 100%;
}

#particles-js>p {
  position: absolute;
  top: 100px;
}

JS:

$(function() {
  particlesJS("particles-js", {
    "particles": {
      "number": {
        "value": 80,
        "density": {
          "enable": true,
          "value_area": 800
        }
      },
      "color": {
        "value": "#ffffff"
      },
      "shape": {
        "type": "circle",
        "stroke": {
          "width": 0,
          "color": "#000000"
        },
        "polygon": {
          "nb_sides": 5
        },
        "image": {
          "src": "img/github.svg",
          "width": 100,
          "height": 100
        }
      },
      "opacity": {
        "value": 0.5,
        "random": false,
        "anim": {
          "enable": false,
          "speed": 1,
          "opacity_min": 0.1,
          "sync": false
        }
      },
      "size": {
        "value": 3,
        "random": true,
        "anim": {
          "enable": false,
          "speed": 40,
          "size_min": 0.1,
          "sync": false
        }
      },
      "line_linked": {
        "enable": true,
        "distance": 150,
        "color": "#ffffff",
        "opacity": 0.4,
        "width": 1
      },
      "move": {
        "enable": true,
        "speed": 6,
        "direction": "none",
        "random": false,
        "straight": false,
        "out_mode": "out",
        "bounce": false,
        "attract": {
          "enable": false,
          "rotateX": 600,
          "rotateY": 1200
        }
      }
    },
    "interactivity": {
      "detect_on": "canvas",
      "events": {
        "onhover": {
          "enable": true,
          "mode": "repulse"
        },
        "onclick": {
          "enable": true,
          "mode": "push"
        },
        "resize": true
      },
      "modes": {
        "grab": {
          "distance": 400,
          "line_linked": {
            "opacity": 1
          }
        },
        "bubble": {
          "distance": 400,
          "size": 40,
          "duration": 2,
          "opacity": 4,
          "speed": 3
        },
        "repulse": {
          "distance": 200,
          "duration": 0.4
        },
        "push": {
          "particles_nb": 4
        },
        "remove": {
          "particles_nb": 2
        }
      }
    },
    "retina_detect": true
  });
  var update;
  update = function() {
    if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) {}
    requestAnimationFrame(update);
  };
  requestAnimationFrame(update);
});

您只是忘记在页面中包含 jQuery 和 particles.js:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/particles.js/2.0.0/particles.min.js"></script>

https://jsfiddle.net/2g56xcty/1/