开发者

OSX 10.7 $(window).width() returning the wrong value

I can't be the first to notice this but ever since 10.7 came out and they implemented the new style of scrollbars $(window).width() and $(window).height() no longer correctly return the size of the browser windows vi开发者_如何学Pythonewport....

Lets say you want to set a div the size of the browser window on load eh...

// load jquery //
    
<div id="bob">
</div>
    
    <script>
      $('#bob').width($(window).width()).height($(window).height());
    </script>

and what ends up happening is something like this

OSX 10.7 $(window).width() returning the wrong value

To this I ask WTF?

here is an example of the issue

http://lab.aerotwist.com/webgl/a3/vertex-manipulation/


Do the elements containing #bob have margin or padding? If they do, that could be adding more space beyond the width and height of #bob, forcing scrollbars to appear.

If that's the problem, you could fix that by adding CSS like this:

html, body, #bob {
    margin: 0;
    padding: 0;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜