I have a page with exactly one visible element: a canvas. I am setting the canvas' width & height to be exactly the width and height of the window (window.innerWidth
and window.innerHeight
), however horizontal and vertical scroll bars still appear and allow me to scroll around a very small amount. None of my elements have any border, padding, or margin (including body
, which I specifically set to have none). Is there a better way to make a canvas take up the entire screen, or should I simply subtract a fixed amount from the width & height, and what would that be?
Asked
Active
Viewed 347 times
0

Moiré
- 75
- 1
- 8
-
1Hi! We can't help you with code we can't see. :-) Please update your question with a [mcve] demonstrating the problem, ideally a **runnable** one using Stack Snippets (the `[<>]` toolbar button); [here's how to do one](https://meta.stackoverflow.com/questions/358992/). It sounds like margins or padding are coming into it, but again, it's impossible to say without seeing the code. – T.J. Crowder Nov 14 '21 at 08:56
-
2Now that we have a sweet _description_ of the code, can we have the code please? – Jeremy Thille Nov 14 '21 at 08:56
-
I don't know why I submitted the code at the time, I probably should have (It was late at night). The solution in there works, as does the solution from Mr Proud. I don't know which one is "better" so I'll use the latter. I'll try to include minimum reproducible examples in the future. – Moiré Nov 14 '21 at 19:07
1 Answers
1
Add style with overflow of hidden
.
<style>
body {
overflow: hidden;
}
</style>

Pradip Dhakal
- 1,872
- 1
- 12
- 29

Mr Proud
- 50
- 5