[英]How to make width and height canvas equal to browser size in Iphone
i have a problem related to width and height canvas in Iphone browser. 我在iPhone浏览器中遇到与宽度和高度画布有关的问题。 In the first loading i am trying to make this code to make width and height canvas full page. 在第一次加载中,我试图使此代码使画布的宽度和高度全页显示。 The size is larg as expected, if the first loading in Portrait mode, but not in landscape mode. 如果在纵向模式下首次加载,但在横向模式下未首次加载,则大小为预期的大。 Is there another way to grab full size both Portrait and landscape. 是否有另一种方法可以同时捕获纵向和横向全尺寸。
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.