Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
How do I get the width of a letter?
Old 08-25-2007, 06:20 AM How do I get the width of a letter?
aatiis's Avatar
Skilled Talker

Posts: 53
Name: Attila Oláh
Location: Serbia
Trades: 0
I'm trying to animate an <h1> on a letter-by-letter basis. As I can't do this whit the tag itself, I'll have to replace it. So I get it's DOM object in JavaScript and the element's child node's value is the text I need to put in the same place but in separate tags (<span>'s perhaps). I can grab all the font-* properties of the original, the problem is with the positioning of the new ones. After all, I'll have to use relative positioning, otherwise I'll end up stuck trying to correct positions every time an 'onresize' event happens.
Now how do I put the second letter after the first one to be in the exact place where the original tag's second letter was? Also, it has to be all in one line even even the window is
too small to display it, so I'm pretty sure I'm gonna need relative positioning.
Any ideas? Or any other way of 'letterizing' tags?
__________________

Please login or register to view this content. Registration is FREE
:: my web design blog
aatiis is offline
Reply With Quote
View Public Profile Visit aatiis's homepage!
 
 
Register now for full access!
Old 08-25-2007, 06:44 AM Re: How do I get the width of a letter?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The only way I can think of off-hand is to have each letter in a independent span.
a span being an inline element will simply take up the space it's content needs by butting up to the previous element and pushing the following elements along the width of the block <hx> element . This way you don't need to change positioning into relative and using the document flow to your advantage rather than trying to work against it.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-25-2007, 11:20 AM Re: How do I get the width of a letter?
aatiis's Avatar
Skilled Talker

Posts: 53
Name: Attila Oláh
Location: Serbia
Trades: 0
Thanks chrishirst. I knew a that separate spans were necessary, but somehow I got used to absolute/relative positioning, though I know it's a bad habit. If I use the document flow, I think the only thing I need to care aboout is the letter-spacing, which is either zero, or if it's different, I just have to set the left and right padding of the spans. The only thing about document flow is that it will brake into lines when the window is too small to display them in one line. Anyway it's not a big problem, thanksalot for your suggestion.
__________________

Please login or register to view this content. Registration is FREE
:: my web design blog
aatiis is offline
Reply With Quote
View Public Profile Visit aatiis's homepage!
 
Old 08-25-2007, 01:33 PM Re: How do I get the width of a letter?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
This isn't the same output, but it is the same concept:

http://www.mikeindustries.com/sifr/

It replaces the individual letters with Flash letters for any font that you want. Maybe you can hack this script enough to do what you want.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 08-25-2007, 02:25 PM Re: How do I get the width of a letter?
aatiis's Avatar
Skilled Talker

Posts: 53
Name: Attila Oláh
Location: Serbia
Trades: 0
Wow! That's almost what I need! They even have an example page, I could take a look at the JavaScript there, I don't need the Flash anyway. Thanks a lot for this link!
__________________

Please login or register to view this content. Registration is FREE
:: my web design blog
aatiis is offline
Reply With Quote
View Public Profile Visit aatiis's homepage!
 
Old 08-25-2007, 02:27 PM Re: How do I get the width of a letter?
aatiis's Avatar
Skilled Talker

Posts: 53
Name: Attila Oláh
Location: Serbia
Trades: 0
OMG there's a problem with my internet connection! Sorry about that!
__________________

Please login or register to view this content. Registration is FREE
:: my web design blog
aatiis is offline
Reply With Quote
View Public Profile Visit aatiis's homepage!
 
Reply     « Reply to How do I get the width of a letter?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46039 seconds with 12 queries