Skip to content

Instantly share code, notes, and snippets.

@KenoLeon
Last active June 2, 2016 02:31
Show Gist options
  • Select an option

  • Save KenoLeon/2a6164035635b5f1d0e18d5b7b375d72 to your computer and use it in GitHub Desktop.

Select an option

Save KenoLeon/2a6164035635b5f1d0e18d5b7b375d72 to your computer and use it in GitHub Desktop.
Canvas 001
<canvas id="canvas-001"></canvas>
var canvas = document.getElementById("canvas-001");
var ctx = canvas.getContext("2d");
canvas.width = 800;
canvas.height = 200;
// color through fillstyle :
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 600, 100);
// Background Color through vanilla Js :
document.getElementById("canvas-001").style.backgroundColor = "lightblue";
// Background Color through Jquery :
//$("#canvas-001").css("background-color", "darkblue");
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
/* #canvas-001{
background-color: blue;
} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment