有两种方法:1.JavaScript 2.CSS
1:
< title >Canvas Resize</ title > |
< script type = "text/javascript" > |
function resize_canvas(){ |
canvas = document.getElementById("canvas"); |
if (canvas.width < window.innerWidth ) |
canvas.width = window .innerWidth; |
if (canvas.height < window.innerHeight) |
canvas.height = window .innerHeight; |
< body onresize = "resize_canvas()" > |
< canvas id = "canvas" >Your browser doesn't support canvas</ canvas > |
2:
height: 100%; width: 100%; border: 1px solid black; |
< canvas id = "myCanvas" >(Your browser doesn't support canvas)</ canvas > |
转载于:https://www.cnblogs.com/watchtower/archive/2011/09/28/2194173.html