Basically, I'm creating a matching game. When I select an item(e.g. pear as seen in picture), it will translate to the right. However, it will end up being on top of the line drawn on the canvas. I want the line to be on top of the image and not the other way round.
I've tried using z-index for canvas to be greater than img but it does not work. Any idea how to fix this?
HTML
<table class="first">
<tr>
<td>
<ul class="firstleft">
/*some images to be filled here*/
</ul>
</td>
<td>
<canvas id="myCanvas" resize></canvas>
</td>
<td>
<ul class="firstright">
/*some images to be filled here*/
</ul>
</td>
</tr>
</table>
CSS
img {
z-index: 1;
}
canvas {
z-index: 20;
}
JS
var canvas = document.getElementById('myCanvas');
ctx = canvas.getContext("2d")
ctx.lineWidth = 6;
ctx.strokeStyle = "#333";
/* Drawing part using an example*/
ctx.beginPath();
ctx.moveTo(100, 250);
ctx.bezierCurveTo(150, 100, 350, 100, 400, 250);
ctx.stroke();