473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do I compensate for font size?

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.

--
George Hester
__________________________________
Jul 20 '05 #1
4 2511
"George Hester" <he********@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.
Jul 20 '05 #2
Ivo
> "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
Jul 20 '05 #3
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/
Jul 20 '05 #4
catch the true width. I did it of sorts. Put the size in a pixel the font could represent then use a scaling factor.

--
George Hester
__________________________________
"Harlan Messinger" <hm*******************@comcast.net> wrote in message news:8n********************************@4ax.com...
"George Hester" <he********@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.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
9
by: Dr John Stockton | last post by:
Assuming default set-ups and considering all reasonable browsers, whatever that may mean, what should an author expect that his readers in general will see (with visual browsers) for a page with...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
16
by: maya | last post by:
I have heard so much preaching here about how font sizes should be set as percentages so users can change font-sizes on their browsers... ok, so now at work am working on a site where we need to do...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
6
by: Miro | last post by:
Is there a way to / or a mathematical formula to see if a font size is 'too big' for a label. I have a label that is docked to 'fill' a form, and I want to resize that font based on the width...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.