Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 viewport....

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 enter image description here

To this I ask WTF?

here is an example of the issue

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

like image 532
samccone Avatar asked Mar 04 '26 17:03

samccone


1 Answers

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;
}
like image 83
icktoofay Avatar answered Mar 07 '26 05:03

icktoofay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!