Canvas element covering the entire screen?

Posted by Stefan Kendall on Stack Overflow See other posts from Stack Overflow or by Stefan Kendall
Published on 2010-05-27T03:25:40Z Indexed on 2010/05/27 3:31 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

I'm trying to use <canvas> in iPhone Safari, and if I place the element in the body, there are unused pixels to the left and top of the element. I tried specifying margin:0;padding:0 with CSS to no avail.

What's going on here?

<html>
<head>
        $(document).ready(function()
        {
            $('#screen').attr("height", $(window).height() );
            $('#screen').attr("width", $(window).width() );

            //prevent scrolling
            $(document).bind('touchstart touchmove', function(e)
            {
                e.preventDefault();
            });
        });
    </script>
</head>
<body>
<canvas id = "screen">
</canvas>
</body>
</html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css