Fullscreen HTML Element using window.innerHeight/Width different with DOCTYPE
I'm trying to make an HTML5 canvas element fullscreen with the window.innerHeight and innerWidth properties.
Unfortunately, on Chrome 10, when I set use the following doctype:
<!DOCTYPE HTML>
...there is some extra scrolling space indicated by scroll bars which shouldn't appear.
Without a doctype, everything is fine.
The element is an HTML5 canvas, so styling with 100% will only stretch the content.
Is it worth using a doctype which breaks my functionality (without which might be bad?), or should I subtract, s开发者_开发知识库ay, 15px from the values in order to keep scroll bars from appearing? (which is kludgy)
It is surely because of the default padding found on the body element of the page. Remove all default padding and margins using:
* {
padding: 0;
margin: 0;
}
精彩评论