Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: module to measure string in pixels

by dws (Chancellor)
on May 25, 2005 at 19:35 UTC ( [id://460430]=note: print w/replies, xml ) Need Help??


in reply to module to measure string in pixels

I thought if there is any way to measure the expected length in pixels with Perl. You guys know of any?

That information isn't available on the server side, since the server doesn't have knowledge of what fonts the user has installed on the client side, and browsers do font substitution if the requested font isn't available.

What you could do is use CSS to specify a fixed-width font for the option text. Something like (untested):

<style type="text/css"> #form_s option { font: "courier new", monospace; } </style>
then you can line up your text by counting characters.

Replies are listed 'Best First'.
Re^2: module to measure string in pixels
by ww (Archbishop) on May 25, 2005 at 19:50 UTC
    dws ++! Very good.
    catch: user can/may have overiden your style sheet.
    bottom line: should work for most

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://460430]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-26 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found