You are here: Re: Calculate length of string in pixels? « All PHP « IT news, forums, messages
Re: Calculate length of string in pixels?

Posted by Andy Hassall on 07/30/05 15:48

On Sat, 30 Jul 2005 13:15:56 +0200, "Bas Varkevisser"
<b.varkevisser_at_hccnet.nl> wrote:

>I need to calculate the length of a string in pixels to see if a text
>exactly fits in a fixed-width table.

What sort of table? HTML table? In which case, no, you can't, not exactly or
reliably anyway, since browsers don't have to use the fixed font size you
specify in CSS, and for non-fixed-width fonts you can't always tell what actual
font the end user's browser will use, so you don't know the character widths.

It might be possible with some fairly dodgy Javascript.

Is there maybe something you could do with the "overflow" CSS property to get
the text clipped if it goes past the end of the cell?

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация