Skip to content Skip to sidebar Skip to footer

Set The Background In Canvas Using Layer (zindex)

I need to get a background on canvas using layers. Variable for it's background. I know I should use CSS and set the z-index, but do not know how to do it in this case. JS: functio

Solution 1:

The Canvas element is not designed to address layers within the element, you'll need to approach your problem using multiple canvas elements instead.

Here's a good article to assist you with the approach

Solution 2:

If you're wanting to display multiple images on the same layer (canvas) then to order the images just draw them to the screen in the order you want them to display. The first drawn images will be at the bottom with each draw drawing on top.

If you want to treat layers as individual canvases, you can use css to set the z-index, or use Javascript like so:

canvas.style.zIndex = 99;

Post a Comment for "Set The Background In Canvas Using Layer (zindex)"