我的canvas元素目前具有以下属性:
var c = document.getElementById("c");
var ctx = c.getContext("2d");
//making the canvas full screen
c.height = window.innerHeight;
c.width = window.innerWidth;
当我将画布放在一个内容超出屏幕高度的页面上时,当我向下滚动时画布会切断,这是预料之中的。如何更改height属性以使画布延伸到页面上的内容?
答案 0 :(得分:0)
使用此:
var c = document.getElementById("c");
var ctx = c.getContext("2d");
//making the canvas full screen
c.height = document.getElementsByTagName('body')[0].scrollHeight;
c.width = window.innerWidth;