+ 1
Responsive Canvas using JavaScript
What is the best, and least complicated, way to make a JavaScript created canvas automatically adjust to the width and height of the device screen?
2 Answers
+ 1
Add this
window.onload = function() {
var canvas = document.getElementsByTagName("canvas")[0];
canvas.width = window.screen.availWidth;
canvas.height = window.screen.availHeight;
}
https://code.sololearn.com/WWFBdeU0nnZf/?ref=app
+ 1
Thank you! This worked perfectly!