I am trying to set the width/height of a canvas element to fill the container it is in. Currently it works, but when it fills the body, scrollbars are added.
let masterCanvas = document.querySelector('canvas');
let parent = masterCanvas.parentElement;
masterCanvas.width = parent.offsetWidth;
masterCanvas.height = parent.offsetHeight;
I have the following styles:
<style>
body, html { padding: 0; margin: 0; width: 100vw; height: 100vh; }
* { box-sizing: border-box; }
</style>
And the following body:
<body>
<canvas></canvas>
</body>
Here is a fiddle that demonstrates this: https://jsfiddle.net/ynkcfsud/