Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Q: Retrieve length (in pixels) of rendered string?? >Thread Next - Re: Q: Retrieve length (in pixels) of rendered string?? Re: Q: Retrieve length (in pixels) of rendered string??To: NULL Date: 12/12/2005 8:33:00 AM
"Neil Smith [MVP Digital Media]" <neil@n...> wrote in message
news:2k4mp1162nc8t8rr3q417l4rbd7ou5r31b@4......
> Not really javascript even without a lot of ugly hackery : You have to
> consider how HTML works - if you insert a paragraph or DIV for
> example, and give it a style="border: 1px solid red" you can see the
> content (text) and also that the container fills the browser window to
> 100% width by default.
>
> So in that case, your content width is (whatever the width of the
> browser window is) : You can check this by asking for the clientWidth
> or scrollWidth properties.
>
> Also, you have to consider that using proportional fonts (arial,
> verdana, pretty much anything except courier) then the character width
> will vary, eg an 'i' is much narrower than a 'm' for example. The only
> way to fix those widths is with a fixed width font (eg courier in your
> CSS) or to use a <pre /> element which applies fixed width fonts by
> default in all browsers (not necessarily the same font though, so the
> width of the container could *still* vary ;-)
>
> However I think whatever your intention is, you're probably
> approaching this from the wrong angle. You're starting with a solution
> and want to know how to make that solution, without proposing what
> your actual problem is. I'll try to read between the lines :
>
> Why is it you need to determine the number of pixels of a marquee ?
>
> Would it help to know for example that you can use CSS overflow
> properties to fix the width of an item and clip the contained text ?
>
> For example :
>
> <html>
> <head>
> <style type="text/css">
> p {
> border: 1px solid red;
> width: 200px;
> height: 18px;
> overflow: hidden;
> }
> </style>
> </head>
> <body>
> <p id="test">this is a test to see how wide my client
> paragraph will go</p>
> <p id="test2">this is a short paragraph</p>
> </body>
>
>
> That will give you 2 paragraphs which fit in a defined space, and the
> rightmost words of the longer paragraph are clipped from view by the
> browser (actually it splits the string at a space or soft-hyphen, and
> won't display words which don't fit in the bounding box).
>
> http://www.w3.org/TR/CSS21/visufx.html#overflow
>
> So in general, stick to exploiting the browser's rendering capabilties
> along with CSS and you'll probably make your life much simpler.
>
> There are lots of decent examples of what you can do with
> CSS+Javascript on Quirksmode among many websites :
>
> http://www.quirksmode.org/js/bilingual.html
> http://www.alistapart.com/articles/elastic/
>
> If you're in any doubt about the capabilties of CSS, then
> http://www.csszengarden.com/ is always worth a weekly visit ;-)
>
> HTH
> Cheers - Neil
Well, we were exploring the possibility of keeping multiple marquees in
synch so that the messages would all start scrolling at the same time and
maintain that. We've since found that some of the text in the marquees will
likely be rather long which would preclude us from keeping them all in
synch. I was just continuing the research out of curiosity's sake in case
something did come up in the future.
Thanks...
Jerry
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
