From: August Karlstrom on
Hi,

I'm trying to get the width of a span element (with clientWidth) but the
browser does not take the font size setting in an external stylesheet
into account. If I add the font size setting directly to the HTML
document (in a style element or inline) I get the correct value. Any ideas?


Thanks,

August
From: Jorge on
On Apr 1, 5:06 pm, August Karlstrom <fusionf...(a)gmail.com> wrote:
> Hi,
>
> I'm trying to get the width of a span element (with clientWidth) but the
> browser does not take the font size setting in an external stylesheet
> into account. If I add the font size setting directly to the HTML
> document (in a style element or inline) I get the correct value. Any ideas?
>
> Thanks,

element.offsetWidth
--
Jorge.
From: August Karlstrom on
Jorge wrote:
> On Apr 1, 5:06 pm, August Karlstrom <fusionf...(a)gmail.com> wrote:
>> Hi,
>>
>> I'm trying to get the width of a span element (with clientWidth) but the
>> browser does not take the font size setting in an external stylesheet
>> into account. If I add the font size setting directly to the HTML
>> document (in a style element or inline) I get the correct value. Any ideas?
>>
>> Thanks,
>
> element.offsetWidth

Sorry, it's offsetWidth that I use, not clientWidth as I stated so the
problem persists.


August
From: Thomas Allen on
On Apr 1, 11:06 am, August Karlstrom <fusionf...(a)gmail.com> wrote:
> I'm trying to get the width [...] but the browser does not take the
> font size setting in an external stylesheet into account.

offsetWidth just returns the width of the element's box, and font
sizes are accounted for when sizing said box. The way that the styles
are loaded, to the best of my knowledge, is irrelevant in this
regard.

Perhaps your script that measures the element is executing before the
external CSS has finished loading, or is applied to the element in
question? That may explain why your <style> version works as expected,
should that tag occur in the document before your script (as a rule of
thumb, and not for scripting reasons, I and others recommend loading
scripts after stylesheets).

Thomas
From: Thomas 'PointedEars' Lahn on
August Karlstrom wrote:

> I'm trying to get the width of a span element (with [offsetWidth]) but the
> browser does not take the font size setting in an external stylesheet
> into account. If I add the font size setting directly to the HTML
> document (in a style element or inline) I get the correct value. Any
> ideas?

ISTM you have a CSS problem, not a script/DOM problem.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16