在Chrome中调整大小时,游戏画布不适合整个页面

时间:2015-09-09 20:21:40

标签: html css google-chrome cocos2d-js

我创建了一个cocos2d-javascript游戏并在Chrome上进行测试。网页的HTML是

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Testing</title>
    <link rel="icon" type="image/GIF" href="res/favicon.ico"/>
    <meta name="viewport" content="width=100%, initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="full-screen" content="yes"/>
    <meta name="screen-orientation" content="landscape"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="360-fullscreen" content="true"/>
    <style>
        body, canvas, div {
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            -khtml-user-select: none;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            width: 100%;
            height: 100%;
            margin: 0px;
        }
    </style>
</head>
<body style="padding:0; margin: 0; background: #000; width:100%; height:100%; margin: 0px;">
<script src="res/loading.js"></script>
<canvas id="gameCanvas" width="100%" height="100%"></canvas>
<script src="frameworks/cocos2d-html5/CCBoot.js"></script>
<script cocos src="main.js"></script>
</body>
</html>

正如您所看到的,我将其设置为使画布适合整个页面。这就是游戏的外观(默认为500x500):

enter image description here

如果我调整窗口大小,画布通常会正确调整大小。但是有时它会有某种形式或余量:

enter image description here

有什么问题?我想问题是HTML本身,而不是cocos2d。

Chrome似乎只会出现这种情况。 Firefox似乎很好。

我正在使用Mac OSX Yosemite。

0 个答案:

没有答案