HTML5 Canvas scrolling

I implemented this <canvas> custom code into my project. It seems to be working for the initial hero section but I only got it to work when both the canvas and the hero section are fixed. The canvas disappears if any of this is changed. This is preventing me from adding additional sections. What am I missing here?

Here is the read-only link to the project

Turns out I need to target the <canvas> HTML element itself and not the css selector .canvas

<style> canvas { position: absolute; z-index: -1; top: 0px; width: 100%; } </style>

1 Like