Search code examples
javascripthtmlcssparticles.js

Particles JS is not covering full page


Hello!

My problem is with Particles JS, it doesn't cover my page. There is a space at the top. enter image description here

HTML:

...
<body>
    ...
        <div id="particles-js"></div>
        <img alt="Server Name" draggable="false" id="Logo" src="assets/img/logo.png">
        <div id="Navigation">
            <a href="#"><img alt="Forums" draggable="false" src="assets/img/icon_exemple.png"></a>
            <a href="#"><img alt="Store" draggable="false" src="assets/img/icon_exemple.png"></a>
            <a href="#"><img alt="Vote" draggable="false" src="assets/img/icon_exemple.png"></a>
        </div>
        <button id="Server" onclick="copyToClipboard('server.ip:port')"><span>Join to us</span></button>
    ...
</body>
...

CSS:

...
body {
  background-image: url(../img/background.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  height: 100vh;
}
#particles-js {
  height: 100%;
  width: 100%;
  position: fixed;
  z-index: -100;
}
...

I tried to solve the problem myself trying different options but nothing.


Solution

  • You should add position values to #particle-js

    #particles-js {
      height: 100%;
      width: 100%;
      position: fixed;
      z-index: -100;
      top:0;
      left:0;
    }