简体   繁体   English

如何使我的 canvas 区域适合 iphone 浏览器?

[英]How can i make my canvas area fit to the iphone browser?

I ve created a game using HTML5.我使用 HTML5 创建了一个游戏。 the canvas size is 320x480. canvas 尺寸为 320x480。 When the webpage opens in the browser of an iphone the canvas area will be placed in the left top corner of the browser and unless i zoom it i cannot play the game.当网页在 iphone 的浏览器中打开时,canvas 区域将位于浏览器的左上角,除非我放大它,否则我无法玩游戏。 What is that i can do.. please help.我能做什么..请帮忙。 Thanks.谢谢。

You need to set the meta tag for viewport to the size of the iPhone screen.您需要将视口的元标记设置为 iPhone 屏幕的大小。

<meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0;"/>

This will scale the page correctly so that you do not have to zoom in at first, and will prevent the user from scaling after the page has opened.这将正确缩放页面,因此您不必首先放大,并且会阻止用户在页面打开后缩放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM