I'm currently attempting to position a div element on top of a canvas on the center of my webpage in order to create a start screen for a game. This start screen will display options like "Play game" and "Settings". Despite conducting thorough research online and reviewing various examples, I have been unable to achieve the desired result. Here is the code I am working with:
<div id="gamecontainer">
<canvas id="myCanvas" width="800" height="600">
Sorry, <strong>CANVAS</strong> is not supported by your browser. Get a more recent one to play my game!
</canvas>
<div id="gamestartscreen" class="gamelayer">
<img src="images/icons/play.png" alt="Play Game" onclick="alert('ceve');"><br>
<img src="images/icons/settings.png" alt="Settings">
</div>
</div>
Here is the associated CSS:
#gamecontainer {
width: 800px;
height: 600px;
background-color: beige;
border: 1px solid black;
position: relative;
margin: 0 auto;
}
.gamelayer {
width: 800px;
height: 600px;
position: absolute;
display: none;
z-index: 0;
}
/* Screen for the main menu (Like Play, Settings, etc.) */
#gamestartscreen {
position: relative;
margin: 0 auto;
}
#gamestartscreen img {
margin: 10px;
cursor: pointer;
}
I would greatly appreciate any guidance on what may be incorrect in my implementation.