Algernop K. Algernop K. - 1 year ago 303
HTML Question

Get particles.js on the correct layer?

I can't make particles.js work as a background. It covers the entire page, I've tried setting a higher z-index (50) for everything I want to cover particles.js with. Here's the particles codepen. The codepen has no background, therefor the particles are not visible.

The code below is what I'm trying to set as background for

<section id="services">

<!-- particles.js container -->
<div id="particles-js"></div>
<!-- stats - count particles -->
<!-- particles.js lib - -->
<script src=""></script>
<!-- stats.js lib --> <script src=""></script>

The problem is that it covers everything inside
as well, not sure why.

The code you're about to see is nothing but a butchered ole' bootstrap template. Never intended to make any real use of it in the first place, hence the confusing amount of style attributes.

<section id="services" style="padding:10px;background-color:black;">
<!-- Here's where I thought fitting it would cause it to work as a background -->
<div class="container" style="padding-top:10px;margin-top:10px;">
<div class="row text-center" style="margin-left:auto;margin-right:auto;">
<div style="margin-left:auto;margin-right:auto;max-width:720px;width:100%;">
<button id="reload" onclick="return returnGame();clearDescr();">
<div class="notspinning" id="theSpinner"></div>
<span id="findMe">
<a href="" id="steamLink" style="color:#333" target="_blank">
<h4 class="service-heading" id="gameName" style="font-family:Montserrat,'Helvetica Neue',Helvetica,Arial,sans-serif;text-transform:uppercase;font-weight: 700;font-size: 22px;color:#777;"></h4>
<p class="text-muted" id="gameDescr" style="min-height:100px;font-family:MyWebFont;"></p>

Any sort of guidance just in the right direction would be much appreciated.

Answer Source

have you tried setting an element as the background, e.g. position: fixed; top:0; right: 0; bottom: 0; left: 0; z-index: 0 and then another div for your content position: relative?


In its simplest form your markup would look like:

    #particle {
      background-color: #b61924;
    #overlay {
<div id="particle"></div>
<div id="overylay">[Your content here]</div>
<script src=""></script>
    var options = {};
    particlesJS("particle", options); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download