2

I'm just wondering how I can make a Javascript Canvas responsive with 90% in height and 100% in width. I have tried:

canvas.width = 100%;
canvas.height = 90%;

However it just brings up syntax errors in my IDE and the canvas no longer renders. Any ideas?

Shaquille Ray
  • 187
  • 2
  • 3
  • 16
  • http://stackoverflow.com/questions/2588181/canvas-is-stretch-when-using-css-but-normal-with-old-width-and-height-proper AND http://stackoverflow.com/questions/10750125/scaling-html5-canvas-width-preserving-w-h-aspect-ratio – Anup Yadav Dec 16 '12 at 05:30

1 Answers1

3

Try canvas.style.width = '100%'; and similarly for height.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592