| Author |
How do I compensate for font size?
|
|
| George Hester 2004-07-26, 11:16 pm |
| I have this in a html <div id=3D"fltUp" align=3D"center"><font =
size=3D"3+" id=3D"fntStop">Howdy</font></div>
Now in JavaScript I can read fltUp.innerText.length. But if the size of =
the font changes fltUp.innerText.length does not. How can I compensate =
the width of Howdy when the font size changes? Thanks.
--=20
George Hester
__________________________________
| |
| Harlan Messinger 2004-07-26, 11:16 pm |
| "George Hester" <hesterloli@hotmail.com> wrote:
>I have this in a html <div id="fltUp" align="center"><font size="3+" id="fntStop">Howdy</font></div>
"3+"?
>
>Now in JavaScript I can read fltUp.innerText.length. But if the size of the font changes fltUp.innerText.length does not.
Of course not. Why would the number of characters change when the font
does?
>How can I compensate the width of Howdy when the font size changes? Thanks.
What do you mean by "compensate"?
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.
| |
|
| > "George Hester" wrote
> I have this in a html
> <div id="fltUp" align="center">
> <font size="3+" id="fntStop">Howdy</font>
> </div>
>
> Now in JavaScript I can read fltUp.innerText.length. But if
> the size of the font changes fltUp.innerText.length does not.
> How can I compensate the width of Howdy when the font
> size changes? Thanks.
Not sure about the + sign in the sizefont tag. Also not sure what you want
to compensate. fltUp.innerText.length will give the number of characters (in
some environments) but width depends on much much more. For that you could
(in some environments) read
document.getElementById('fltUp').offsetWidth
which will give you the width of the element in pixels.
It may turn out the div is as wide as the window. Then read the width the
font tag itself. The font tag is deprecated by the way. Use a span.
And post in plain text format please.
Thanks,
Ivo
| |
|
| George Hester wrote:
> <div id="fltUp" align="center"><font
> size="3+" id="fntStop">Howdy</font></div>
>
> Now in JavaScript I can read fltUp.innerText.length. But if the
> size of the font changes fltUp.innerText.length does not. How can
> I compensate the width of Howdy when the font size changes?
"The font size chosen by the user as a comfortable default (1 em)
provides more truly useful information about the rendering environment
than all the resolution-sniffing, window-querying, 'open-this-wide'
logic you can throw at the problem."
- Todd Fahrner
In other words, use css and the em unit to size what you need to size.
No js needed.
--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
| |
| George Hester 2004-07-30, 7:16 pm |
| catch the true width. I did it of sorts. Put the size in a pixel the =
font could represent then use a scaling factor.
--=20
George Hester
__________________________________
"Harlan Messinger" <hmessinger.removethis@comcast.net> wrote in message =
news:8ndbg01tuqb3qb5ajm8q4qoivid34bl4l1@4ax.com...
> "George Hester" <hesterloli@hotmail.com> wrote:
>=20
size=3D"3+" id=3D"fntStop">Howdy</font></div>[color=darkred]
>=20
> "3+"?
>=20
of the font changes fltUp.innerText.length does not. =20[color=darkred]
>=20
> Of course not. Why would the number of characters change when the font
> does?
>=20
Thanks.[color=darkred]
>=20
> What do you mean by "compensate"?
>=20
> --=20
> Harlan Messinger
> Remove the first dot from my e-mail address.
> Veuillez =F4ter le premier point de mon adresse de courriel.
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |