+ 1
Why won't my canvas work?
I was trying to set up an HTML5 canvas for a new code, like I have done many times, but for some reason it won't work. Why? https://code.sololearn.com/WfOeQT6BNS1t/?ref=app
5 Respostas
+ 4
1. your code does not have a <body>
2. when the height of the body is not defined, the body is only the height that just fits the contents – which is not necessarily the screen size.
suggestion:
make a proper <body>, give the body a fixed size that is as large as the screen.
+ 1
How do I apply a fixed size?
+ 1
Thanks
0
For instance
body {
width: 100vw;
height: 100vh;
}
0
Follow what Lisa mentioned, also, I hsve spotted an error in your HTML file, you have made a typo in the closing tag of body, it should be </body> instead of <body/>.