The problem I am encountering with particles.js

Having an issue with the particles.js library where the particles are displaying beneath the elements despite setting the Z-index. I have tried various solutions from CSS, Stack Overflow, Google, and YouTube but none have been effective.

Here is my code snippet:

 // JavaScript code
const particlesJSON = {
    "particles": {
        ...
        [particle settings here]
        ...
    }
}
particlesJS("sec", particlesJSON) 
// Sample CSS Code
*{
    margin: 0;
    padding: 0;
    height: 100vh;
}

.container{
    max-width: 100%;
    padding-left: 70px;
    ...
    [more CSS styles here]
    ...
}
// HTML Structure
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Particles</title>
</head>

<body>
  
  <section id="sec">

    <div class="container">
       <!-- Card components -->
       <div class="row">
          ...
          [card components structure]
          ...
       </div>
   </div>
    
 </section>

  <script src="https://cdn.jsdelivr.net/npm/particles.min.js"></script>
  <script src="json-particles.js"></script>

  // Bootstrap Javascript files
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>
</html>

Answer №1

Make your canvas stationary and place it at the top.

 const particlesJSON = {
    "particles": {
        "number": {
            "value": 40,
            "density": {
                "enable": true,
                "value_area": 500
            }
        },
        "color": {
            "value": "#ff9800"
        },
        "shape": {
            "type": "polygon",
            "stroke": {
                "width": 2,
                "color": "#ff9800"
            },
            "polygon": {
                "nb_sides": 6
            },
            "image": {
                "src": "img/github.svg",
                "width": 100,
                "height": 100
            }
        },
        "opacity": {
            "value": 0.5,
            "random": true
        },
        "size": {
            "value": 10,
            "random": true
        },
        "line_linked": {
            "enable": false,
            "distance": 200,
            "color": "#ff5722",
            "opacity": 0.3,
            "width": 2
        },
        "move": {
            "enable": true,
            "speed": 5,
            "direction": "bottom",
            "random": true,
            "straight": true,
            "out_mode": "out",
            "bounce": false,
            "attract": {
                "enable": false,
                "rotateX": 600,
                "rotateY": 1200
            }
        }
    },
    "interactivity": {
        "detect_on": "canvas",
        "events": {
            "onhover": {
                "enable": false,
                "mode": [
                    "grab",
                    "bubble"
                ]
            },
            "onclick": {
                "enable": true,
                "mode": "push"
            },
            "resize": true
        },
        "modes": {
            "grab": {
                "distance": 400,
                "line_linked": {
                    "opacity": 0.7
                }
            },
            "bubble": {
                "distance": 600,
                "size": 12,
                "duration": 1,
                "opacity": 0.8,
                "speed": 2
            },
            "repulse": {
                "distance": 400,
                "duration": 0.4
            },
            "push": {
                "particles_nb": 20
            },
            "remove": {
                "particles_nb": 10
            }
        }
    },
    "retina_detect": true
}

particlesJS("sec", particlesJSON) 
*{
    margin: 0;
    padding: 0;
    height: 100vh;
}
canvas {
    position: fixed;
    top: 0;
}
.container{
    max-width: 100%;
    padding-left: 70px;
    padding-right: 70px;  
}     
.card{
    background-color: rgb(255, 255, 255)!important;
    overflow: hidden;
    border: medium none;
    border-radius: 6px;
    box-shadow: -1px 92px 99px -62px rgba(0,0,0,0.12), 0 25px 65px 0 rgba(0,0,0,0.08);
    height: 80%;
    text-align: center;
}
.testimonials-item{
    padding: 37px;
}
.card-info{
    padding-right: 10px;
    padding-left: 10px;
}
#text1{
    font-size: 23px;
    color: #f0c504c4;
    font-family: 'Nunito', sans-serif;
    margin-bottom: 0;
}
#text2{
    color: #7d8b9b;
    font-size: 15px;
}
.row{
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}
.row2{
    margin-top: 17px;
}
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}
.wow{
    margin-bottom: 30px;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to level out the content in the article using CSS and HTML?

Can anyone help me with CSS and HTML? I have a travel blog and I want to include a related post section similar to Time.com in my articles, but I'm facing an issue. What do I need to achieve this? I want to create a section that looks like the relat ...

What is the best way to combine the average hours, minutes, seconds, and milliseconds in JavaScript?

I am seeking guidance on how to calculate the average of three different times in JavaScript. In the scenario presented below, the average of the three times is calculated as 01:42:22:566. <form action="/action_page.php"> <label for= ...

Dealing with a unique key error in a loop while using React and Google

I've implemented a react-google-maps component that successfully retrieves data from various locations. However, I'm encountering an error message in the console: Warning: Each child in a list should have a unique "key" prop. I made s ...

The issue with HTML5 anchor download attribute for saving files cannot be resolved

When I use an anchor tag like this.. <a class="btn btn-download" href="https://www.anotherdomain.com/file.jpg" download="customname.jpg">Download</a> The file is downloaded as file.jpg instead of customname.jpg Interestingly, it works fine i ...

Obtain a collection of custom objects through an HTTP GET request to be utilized in an Angular 2 application

I am currently grappling with the task of efficiently retrieving a list of custom objects and displaying their contents using an HTML file. Here is a simplified version of the HTTP GET method that I am working with: [HttpGet("/atr/testing")] public List& ...

Explain the inner workings of the setTimeout() function in JavaScript

My goal is to create a line in my code by placing points according to the line equation and adding a 100 millisecond delay before each point is displayed. However, when I try to run the code, it seems to wait for some time and then displays all the points ...

Receiving empty response after attempting a cross-domain POST query with Cross-Origin Resource Sharing

When trying to send data cross domain via a POST request, I am facing an issue where jQuery's success handler is not being called. The technologies being used include Django, Apache, and jQuery. Here is the AJAX request setup that is causing the pro ...

Why am I encountering http://localhost:3000/api/auth/error?error=AccessDenied when implementing Google signin in my Next.js application?

Can someone please assist me in resolving an issue I am facing with my NextJs application using Google signin? Whenever I try to sign in, I get the error message "http://localhost:3000/api/auth/error?error=AccessDenied". Why is this happening? Here is a ...

Changing the tooltip background color in FullCalendar 6 and Bootstrap 5: A step-by-step guide

My FullCalendar agenda displays events with colored backgrounds. However, I want the tooltips for these events to have matching background colors as well. Currently, the tooltips always show up with a black background. Is there a way to dynamically change ...

What is preventing my h1 styles from being applied to an h1 element within a <section> tag?

I have a headline in my header and in another part of the content. I've been told that this can impact SEO, but I'm just starting out by copying other people's pages and trying to replicate their styles without looking at their code. The st ...

What could be causing the image not to be centered inside the <table><td>?

Currently, I am developing a web application with Google Script that generates a dashboard featuring multiple tables. To design the layout, I am utilizing Bootstrap (https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css). Despite ...

Exploring various queries in Firestore

Does anyone know if there is a way to create a sentence similar to this one: return this.db.collection('places', ref => ref.where("CodPais", "<>", pais)).valueChanges(); I have tried using != and <> but neither seem to be valid. ...

only one Collapsible will be open at any given moment

// In the code snippet below, there are three Collapsibles. When one is clicked, it expands, but in order to close it again, you have to click on that particular text. I want to implement a change: if any of the three Collapsibles are already open and I cl ...

Upload dojo.js to my server for use

Check out this link for a working example: It's functioning perfectly. I then copied the HTML and tried running it on my local Apache server. Surprisingly, it worked! However, when I attempted to load the same dojo.js file on my web server, it ...

Utilizing dynamically assigned ng directives in my unique custom directive

I'm in the process of creating a customized table element that looks like this: <datatable items='tableItems' columns='columnsConfig' /> Here, 'tableItems' represents my array of items and 'columnsConfig&apos ...

Building a sub-navigation menu within the main navigation menu

Can anyone help me create a submenu in my navigation menu? My CSS knowledge is limited and I'm encountering some issues. When I add a submenu to the nav menu, it displays as ul li directly. #cssmenu { background: #88BC18; width: auto; z-index ...

Vue: the parent template does not permit the use of v-for directives

Upon creating a simple post list component, I encountered an error when trying to utilize the v-for directive: "eslint-eslint: the template root disallows v-for directives" How can I go about iterating through and displaying each post? To pass data from ...

How can I dynamically update an img src using JavaScript on a PHP webpage?

I have a PHP page where I display image thumbnails. I am trying to implement a feature where the thumbnail expands in another image on mouseover. Here is the PHP code snippet: echo "<tr><td><a href='$imgrow[location]' target=&ap ...

Guide to playing facebook in an iframe with javascript

I'm having trouble playing a Facebook video from an iframe using JavaScript. Can anyone help me figure it out? Here's what I've tried: <div onclick="play_fn()"> click here to play </div> <br> <script> function pla ...

Extract data from selected range using Highcharts

I am working on implementing a Highchart in Angular and I have run into an issue with creating my own range selector dynamically using this.chart.update. Unfortunately, the error "undefined update not a function" keeps popping up. How can I troubleshoot ...