Particles.js: particles are not appearing as background.

Created on 15 Mar 2017  路  8Comments  路  Source: VincentGarreau/particles.js

I tried to vary the z-index as some suggested in stack-overflow, but still the canvas appears only after the div container. How to make it appear as the real background for my contents.?

Most helpful comment

This worked for me. Put this after the content you don't want to have the particles as the background.

<div style="position: absolute; width: 100%; height: 100%;" id="particles-js"></div>

All 8 comments

Any suggestions?

You need to set the div of the particles position as 'absolute' and then subsequent divs with 'relative'. Hope this helps!

What I've done and it worked is

body>

div id="particles-js" width="100%" height="100%">
canvas class="particles-js-canvas-el" width="1583" height="497" style="width: 100%; height: 100%;">/canvas>/div>
div id="asd">!-- here I put the main body of page -->/div>
and css
canvas {
display:block;
position: fixed;
z-index: -10;
}'''

Does this retain the ability to interact with the particles as well? I guess the downside there is you can't have a div under the particles too, right?

I can't interact - it's true

Hey! Just in case you were interested, I found the solution to keeping the interactivity on the particles regardless of what elements are in front of the canvas.

https://github.com/VincentGarreau/particles.js/issues/87 - The creator outlines how to do it here. But essentially in the "Interactivity" section of your JSON or particles.js config, replace the word 'Canvas' with 'Window'.

Thanks. that was useful

This worked for me. Put this after the content you don't want to have the particles as the background.

<div style="position: absolute; width: 100%; height: 100%;" id="particles-js"></div>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tripletto picture tripletto  路  5Comments

Necmttn picture Necmttn  路  6Comments

cosmokrust picture cosmokrust  路  5Comments

Adryd picture Adryd  路  7Comments

ananddharne picture ananddharne  路  3Comments