I want to have this JS - https://codepen.io/jkiss/pen/OVEeqK - as the background of a div element on my front page.
Html
<script src="{% static 'home/animated.js' %}"></script>
<div class = "content-section">
<div id = "canvas-wrap">
<canvas id="nokey"></canvas>
<div class = "bg-1 media" id = "overlay">
<div class = "container">
<img src = "../../../media/pfp.jpg" class = "profile-img img-thumbnail rounded-circle">
<div class = "media-body intro">
<h1 class = "">My Name</h1>
<h4>Aspiring Web Developer</h4>
</div>
</div>
</div>
</div>
CSS
body{
background-color: #222222;
font:inherit;
font-family: Titillium;
margin:0;
padding:0;
}
#canvas-wrap { position:absolute; width:100px; height:50px; z-index:0 }
#canvas-wrap canvas { position: absolute; top:0; left:0; z-index:0 }
#nokey{
background-color: darkblue;
}
.content-section{
margin-left: 50px;
margin-right: 50px;
margin-bottom: 50px;
background: aliceblue;
}
.bg-1 .container{
display: flex;
align-items: center;
justify-content: center;
}
.intro{
flex: none;
margin-top: 200px;
margin-bottom: 200px;
padding-left: 25px;
color: white;
}
What can I do? Currently the canvas takes up all of the screen and the div is created behind it.
Use z-index
CSS property to move div higher other elements:
#nokey{ background-color: darkblue; z-index: 1; // or more, if other elements has one }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.