Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发只使用 html5 画布元素和 javascript 的游戏。我需要能够重新调整它的大小,但不想使用任何库
您可以通过将画布分配给变量来简单地更改画布的宽度和高度,并使用宽度和高度属性。
var canvas = document.getElementById("ID of canvas here"); canvas.width = 500; canvas.height = 500;