Riddik Posted October 21, 2015 Share Posted October 21, 2015 Hi, If game is in <body> then the size is correct: But when the game is place to <div> then the size is wrong and there are additional spaces around canvas in both sides How to fix this and remove that space? body and div style: body{ background-color: black; margin: 0;}#gameContainer{ width: 100%; height: 100%; position: absolute; } Link to comment Share on other sites More sharing options...
chongdashu Posted October 21, 2015 Share Posted October 21, 2015 Probably need more information, but if you are doing position: absolute, you might want to do top: 0px; left: 0px; padding: 0px; too Link to comment Share on other sites More sharing options...
Riddik Posted October 22, 2015 Author Share Posted October 22, 2015 Probably need more information, but if you are doing position: absolute, you might want to do top: 0px; left: 0px; padding: 0px; too I added this to div style, but the issue still present. Here the canvas style in div: You may notice that the canvas has a strange margin parameters. And here correct canvas in body: Link to comment Share on other sites More sharing options...
Riddik Posted October 22, 2015 Author Share Posted October 22, 2015 Oh, seems I find the solution. Just put this code into resize function:var gameContainer = document.getElementById(game.parent);gameContainer.style.width = window.innerWidth + "px";gameContainer.style.height = window.innerHeight + "px"; Link to comment Share on other sites More sharing options...
Recommended Posts