[英]What is the best way to scale an Canvas with css or js to the screen? And how do I make the width of the canvas equal to the height?
[英]How to make width and height canvas equal to browser size in Iphone
我在iPhone浏览器中遇到与宽度和高度画布有关的问题。 在第一次加载中,我试图使此代码使画布的宽度和高度全页显示。 如果在纵向模式下首次加载,但在横向模式下未首次加载,则大小为预期的大。 是否有另一种方法可以同时捕获纵向和横向全尺寸。
var context = document.getElementById("myCanvas").getContext("2d");
var canvasImage = document.getElementById("myCanvas"),
canvasMessage = document.getElementById("myCanvas2"),
canvasImage.width = window.innerWidth;
canvasImage.height = window.innerHeight; // on portrait it give 1091 but not in landscape
canvasMessage.width = window.innerWidth;
canvasMessage.height = window.innerHeight;
它可以帮助您将其包含在HTML页面中
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.