I'm getting two different values for the same selector.width()
and I try to figure out how / why.
Pseudo code:
<div id="wrapper">
<ul>
<li>...</li>
</ul>
</div>
I have a link that toggles the width of the list items between $('#wrapper').width()
and $(window).width()
. More or less regular view to fullscreen and back. If the #wrapper
is a fixed width (e.g., width=500px
) everything is fine.
However, if the wrapper is (for example) width:50%
then I get unexpected results. The .width
is fine (read: correct) when I first display the page. That is, prev / next controls etc line up correctly. If I toggle to fullscreen and then come back again to regular view the .width
value is a couple/few pixels less. I've tried the width=X%
with different value for X
and the difference changes. That is, it's not fixed.
Padding and margins are set to zero so I don't think that's it.
Also, I have a $(window).resize(function()
and if I nudge the window just a bit then the width reading corrects itself. Even if I open Firebug in the bottom is fixes itself.
I understand the pseudo code is vague. I'm just hoping to get some thoughts and direction on how I might be able to pin point where the problem is so I can fix it.