I am trying to use this example: http://html5.litten.com/using-multiple-html5-canvases-as-layers/ to create multiple html5 layers (Actually only need 2) for a background and then an animation on top of that background.
The problem is the example, and many other solutions that suggest layering canvases using z-index, etc. all seem to position the canvas at left:0 and top:0 in absolute position.
For example: html5 - canvas element - Multiple layers html5 - canvas element - Multiple layers
However, what I would like to do, is have the position be dynamic but always so the two canvases are layered on top of each other.
What I've had to do so far is this:
<div id="canvasesdiv" align=center; style="text-align:center; float:center">
<canvas id="bottomlayer-background" style="z-index: 1; border:1px dotted;" align=center>
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
<canvas id="toplayer-movingstuff" style="z-index: 2; border:1px dotted; position:absolute; left:530px; top:83px">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
</div>
The problem with this approach is that I had to manually figure out where the top left of the bottom layer was and then input that into the top layer. But this position is only true for one browser, on one monitor, on full screen, etc. Obviously, not workable.
When I try and have both just be align=center, then what happens is the canvases appear side-by-side instead of layered on top of each other.
When I try to do absolute position for both, the problem with that is the other stuff in the windows, that were originally below the canvases (i.e. text, tables, etc.) suddenly appear underneath the canvases.
Has anyone else been able to solve this problem?
Thanks!