I'm having trouble inserting a <canvas> animation within a <div> element. The current code displays the animation across the entire page, but I would like to contain it within a single section, like this: <div><canvas> </canvas></div>
HTML:
<canvas></canvas>
<h2>hi</h2>
CSS:
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100vh;
font-family: 'Poppins', sans-serif;
background-color: #121212;
display: flex;
align-items: center;
justify-content: center;
}
canvas {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 0;
}
h2 {
font-size: 80px;
color: white;
position: relative;
}