elementor4fun-logo
Last update: August 7, 2018

How to add a particles background effect

COOL PARTICLES BACKGROUND

FOR OXYGEN BUILDER

UPDATE AUGUST 7, 2018 A popular and easy to add effect, that looks pretty cool in the homepage.

Step 1

Load the library :

wp_enqueue_script( 'particles-js', plugin_dir_url( __FILE__ ) . 'assets/js/particles.min.js', '', '', true );

Step 2

Create a DIV, change his height, add a Heading or whatever you want inside.

Step 3

Add a Code Block and in the CSS panel, add :

#div_block-2-103 {
     position:relative;
}
 #div_block-2-103 canvas {
     position:absolute;
}

Replace #div_block-2-103 by your DIV's ID

Step 3

UPDATE : In some case, the particles canvas can be stretched and it doesn't look great. So instead of adding the following code in a Code Block, add it in your own external Javascript file. In the Javascript panel, add the following code (and don't forget, once again, to change the DIV's ID) :

particlesJS("div_block-2-103", 
{
  "particles": {
    "number": {
      "value": 400,
      "density": {
        "enable": true,
        "value_area": 800
      }
    },
    "color": {
      "value": "#fff"
    },
    "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": true,
      "anim": {
        "enable": false,
        "speed": 1,
        "opacity_min": 0.1,
        "sync": false
      }
    },
    "size": {
      "value": 10,
      "random": true,
      "anim": {
        "enable": false,
        "speed": 40,
        "size_min": 0.1,
        "sync": false
      }
    },
    "line_linked": {
      "enable": false,
      "distance": 500,
      "color": "#ffffff",
      "opacity": 0.4,
      "width": 2
    },
    "move": {
      "enable": true,
      "speed": 6,
      "direction": "right",
      "random": false,
      "straight": false,
      "out_mode": "out",
      "bounce": false,
      "attract": {
        "enable": false,
        "rotateX": 631.3181133058181,
        "rotateY": 1262.6362266116362
      }
    }
  },
  "interactivity": {
    "detect_on": "canvas",
    "events": {
      "onhover": {
        "enable": false,
        "mode": "bubble"
      },
      "onclick": {
        "enable": false,
        "mode": "repulse"
      },
      "resize": true
    },
    "modes": {
      "grab": {
        "distance": 400,
        "line_linked": {
          "opacity": 0.5
        }
      },
      "bubble": {
        "distance": 400,
        "size": 4,
        "duration": 0.3,
        "opacity": 1,
        "speed": 3
      },
      "repulse": {
        "distance": 200,
        "duration": 0.4
      },
      "push": {
        "particles_nb": 4
      },
      "remove": {
        "particles_nb": 2
      }
    }
  },
  "retina_detect": true
}

);

And that's it. You should be able to see it right now, in the backend.

So the structure is very simple and we only have 1 DIV + some content and 1 Code Block :

To change the particles effects, you just need to go to this page : https://vincentgarreau.com/particles.js/

Change the settings and click in the Download current config (json) button. Then copy the content and import it in the javascript panel :

particlesJS("div_block-2-103", 

// import the json content here //

);
closealign-justifychevron-downcaret-up