views:

155

answers:

2

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>
A: 

add <style>* {margin:0;padding:0;border:0;position:absolute;width:100%;height:100%}</style>

antimatter15
A: 

margin,padding, and border have no effect.

Use position:absolute; top:0;left:0

Stefan Kendall