First you set the canvas width to 100%
$('#canvas').css('width', '100%');
then update its height base in width
$(window).resize(function(){ $('#canvas').height($('#canvas').width() / 2.031); });
2.031 = 979/482
But you should not attach to $ (window) .resize, as I ... this is bad behavior
Trinh hoang nhu
source share