JSFiddle - React, Tailwind, and code Playground
by djwave28
HTML
<canvas id="canvas" width="400" height="300">
canvas is not supported by this browser
</canvas>
CSS
#canvas {
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin:auto;
}
JavaScript
var canvas = document.getElementById('canvas');
canvas.width = window.innerWidth * .8;
canvas.height = window.innerHeight * .8;
// start working with canvas - paint black to make visible
ctx = canvas.getContext('2d');
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, canvas.width, canvas.height);