Jump to content

Scale game to div


Recommended Posts

Both. To give you an idea, you can set the canvas's style with Javascript like this:

var canvas = document.getElementById("canvas");
var div = document.getElementById("gamediv");

canvas.style.width = gamediv.getBoundingClientRect().width + "px";
canvas.style.height = gamediv.getBoundingClientRect().height + "px";
canvas.width = parseFloat(canvas.style.width);
canvas.height = parseFloat(canvas.style.height);


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...