Make HTML Canvas Fit Screen
I would like to make it so that the HTML Canvas element has a width = to the browser window width, and height = the browser window height. Below is the code I use. HTML:
Solution 1:
Try this for your CSS:
body {
margin: 0;
}
#gameCanvas {
width: 100vw;
height: 100vh;
}
Solution 2:
Try this:
html, body {
height: 100%;
}
#gameCanvas {
width: 100%;
height: 100%;
}
The 100% has to filter down from the html element or else it won't fill the height of the screen.
Post a Comment for "Make HTML Canvas Fit Screen"