Skip to content

Instantly share code, notes, and snippets.

@louisstow
Created May 20, 2013 06:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisstow/5610652 to your computer and use it in GitHub Desktop.
Save louisstow/5610652 to your computer and use it in GitHub Desktop.
Example of a game with 3 canvas layers.
<div id="stage">
<canvas id="ui-layer" width="480" height="320"></canvas>
<canvas id="game-layer" width="480" height="320"></canvas>
<canvas id="background-layer" width="480" height="320"></canvas>
</div>
<style>
#stage {
width: 480px;
height: 320px;
position: relative;
border: 2px solid black
}
canvas { position: absolute; }
#ui-layer { z-index: 3 }
#game-layer { z-index: 2 }
#background-layer { z-index: 1 }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment