简体   繁体   English

如何使宽度和高度画布等于Iphone中的浏览器大小

[英]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.

相关问题 使用 css 或 js 将 Canvas 缩放到屏幕的最佳方法是什么? 以及如何使画布的宽度等于高度? - 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? 防止画布图表JS的大小等于窗口的高度和宽度 - Prevent size of canvas chart js to equal window height and width 浏览器大小(宽度和高度) - Browser size (width and height) 如何制作一个动态画布/网格/行/列,可以调整到浏览器的宽度和高度,同时保持纵横比? - How to make a dynamic canvas/grid/row/column that will adjust to browser width and height, while keeping aspect ratio? 调整浏览器大小后如何获取画布的宽度和高度 - How to get width and height of canvas after resizing the browser 如何在图像编辑器中根据输入的高度和宽度设置画布大小? - how to set canvas size on inputted height and width in my image editor? 如何在Ionic中使元素的高度等于其宽度? - How to make an element's height equal to its width in Ionic? 如何将画布的宽度和高度设置为浏览器的所有高度和宽度而不会溢出? - How to set width and height of canvas to all height and width of browser without overflow? 自动调整画布大小以适应浏览器的宽度和高度 - Auto-resize Canvas to Browser Width & Height 将画布调整为完整的浏览器窗口宽度和高度 - Resizing canvas to full browser window width and height
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM