Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  
  canvas {
    border: 1px solid green;
    background-color: yellow
  }
  #myCanvas { 
    z-index: 1;    
   
    
  }
  #legend { 
    
    height: 80px; 
    width: 80px; 
    background-color: #0000FF;
    
    border: 1px solid red;
  }
</style>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div id="legend" style="top: 100px; position:relative;">
        <p>And is</p>
  </div>
    <canvas id="myCanvas"></canvas> 
    
      
      
 
</body>
   
</html>
 
// Get a reference to the element.
var elem = document.getElementById('myCanvas');
// Always check for properties and methods, to make sure your code doesn't break 
// in other browsers.
if (elem && elem.getContext) {
  // Get the 2d context.
  // Remember: you can only initialize one context per element.
  var context = elem.getContext('2d');
  if (context) {
    // You are done! Now you can draw your first rectangle.
    // You only need to provide the (x,y) coordinates, followed by the width and 
    // height dimensions.
    //context.fillRect(100, 25, 220, 100);
  }
}
var elem2 = document.getElementById('myCanvas2');
if (elem2 && elem2.getContext) {
  context = elem2.getContext('2d');
  if (context) {
    //context.beginFill("#ffff00");
    context.fillRect(0, 0, 220, 100);
    //context.endFill();
  }
}
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers