问题
simply can not understand this problem I have - I need the .outerWidth()
of a <label>
element, but it keeps returning a value that is different from the one I can read out of my firebug?
.outerHeight
works just fine though.
SOLVED: Note to self: custom fonts and calculations of width does not work all that well, lol
回答1:
When you use custom fonts, you must use the .outerHeight
method on $(window).load(function(){}
, not $(document).ready(function(){}
. The first case waits for all the elements of the window to be loaded (including the custom font and the image) otherwise in the second case it is ready before the custom element is loaded and it not know the dimension of it.
回答2:
Maybe you need .outerWidth(true)
wich includes the margin of the element.
http://api.jquery.com/outerWidth/ for more specific information on the outerWidth function.
回答3:
SOLUTION/PROBLEM: I used custom fonts - must be a workaround though - dont have time to find it yet :-D
来源:https://stackoverflow.com/questions/5539602/cant-get-right-width-or-outerwidth-of-label-element