Jump to content

Adding a VantaJS Background

Recommended Posts

Hello,

I am attempting to add a custom background to my squarespace site. Specifically a valnajs background that can be found here:

https://www.vantajs.com/?effect=net#(backgroundAlpha:1,backgroundColor:13223885,color:7370174,maxDistance:24,points:6,showDots:!t,spacing:17)

I can successfully add this javascript and get the resulting image when I use a code block and the following code:

<script src="three.r92.min.js"></script>
<script src="vanta.net.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/100/three.min.js"></script>
<script src="https://www.vantajs.com/dist/vanta.birds.min.js"></script>


<div id=vantajs></div>

<script>
VANTA.BIRDS({
  el: "#vantajs",
});
</script>

 

However, this just inserts the image in that block and does not actually make the image the background of my page. I have tried many ways through the page code-injection feature to add this to my website, specifically the section-background html element, but nothing has worked. Here is an example of one of the methods I am trying when using the page code injection:

<script src="three.r92.min.js"></script>
<script src="vanta.net.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/100/three.min.js"></script>
<script src="https://www.vantajs.com/dist/vanta.birds.min.js"></script>

<script>
 (function(){var x = document.getElementByClassName("section-background"); 
x.setAttribute("id", "vantajs")})();
</script>

<script>
VANTA.BIRDS({
  el: "#vantajs",
});
</script>

 

Any help here would be greatly appreciated.

Link to comment
  • Replies 5
  • Views 3.1k
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.