开发者

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

开发者 https://www.devze.com 2023-03-26 15:30 出处:网络
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 b

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

精彩评论

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