Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Text field text alignment (http://www.velocityreviews.com/forums/t391813-text-field-text-alignment.html)

Karsten Wutzke 12-14-2006 01:16 PM

Text field text alignment
 
Hi all!

How do you right align text within a text field (<input ...> tag) for
decimal/floating point values??

Sorry for this short q, tried many things that don't seem to work.

align="right"
halign="right"

....don't work.

Karsten

PS: is it possible to align at the decimal point?


Jonathan N. Little 12-14-2006 03:01 PM

Re: Text field text alignment
 
Karsten Wutzke wrote:
> Hi all!
>
> How do you right align text within a text field (<input ...> tag) for
> decimal/floating point values??
>
> Sorry for this short q, tried many things that don't seem to work.
>
> align="right"
> halign="right"
>
> ...don't work.


In stylesheet:
/* make right aligned */
..toright { text-align: right; }


HTML:
<input name="test" type="text" size="10" class="toright" value="sample">



> PS: is it possible to align at the decimal point?
>


Not on INPUT elements, on table cells but I believe browser support it
spotty

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Jukka K. Korpela 12-14-2006 09:26 PM

Re: Text field text alignment
 
Scripsit Jonathan N. Little:

>> PS: is it possible to align at the decimal point?
>>

>
> Not on INPUT elements, on table cells but I believe browser support it
> spotty


By the CSS 2.0 specification, you can use text-align: ".", and you could
even use the display property to turn input elements into cells in CSS sense
(i.e., as elements to be rendered as table cells). But string values for
text-align haven't been implemented at all, and the drafts for CSS 2.1 (work
in progress) have this feature removed.

For table cells, there are somewhat contrived techniques to create the
impression of aligning at the decimal point, and they work part of the time.
I guess it would be possible to do something similar with input elements,
using JavaScript to insert special space characters as needed, but it would
not work reliably at all in any open environment.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Jonathan N. Little 12-14-2006 10:05 PM

Re: Text field text alignment
 
Jukka K. Korpela wrote:
> Scripsit Jonathan N. Little:
>
>>> PS: is it possible to align at the decimal point?
>>>

>>
>> Not on INPUT elements, on table cells but I believe browser support it
>> spotty

>
> By the CSS 2.0 specification, you can use text-align: ".", and you could
> even use the display property to turn input elements into cells in CSS
> sense (i.e., as elements to be rendered as table cells). But string
> values for text-align haven't been implemented at all, and the drafts
> for CSS 2.1 (work in progress) have this feature removed.
>
> For table cells, there are somewhat contrived techniques to create the
> impression of aligning at the decimal point, and they work part of the
> time. I guess it would be possible to do something similar with input
> elements, using JavaScript to insert special space characters as needed,
> but it would not work reliably at all in any open environment.
>

I thought I had seen it somewhere but could not find it. Moot though,
because I haven't a browser that supports it.

For OP your best solution is to style for right alignment and make sure
your font is monospace "fix-width" and has a consistent number of
decimal digits.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Bergamot 12-14-2006 10:13 PM

Re: Text field text alignment
 
Jonathan N. Little wrote:
>
> .toright { text-align: right; }
>
> <input name="test" type="text" size="10" class="toright" value="sample">


You should use a class name that describes the content, not the style.
In the OP's case, class="amount" or something else indicative of numeric
content would be more suitable.

--
Berg

Jonathan N. Little 12-14-2006 11:09 PM

Re: Text field text alignment
 
Bergamot wrote:
> Jonathan N. Little wrote:
>> .toright { text-align: right; }
>>
>> <input name="test" type="text" size="10" class="toright" value="sample">

>
> You should use a class name that describes the content, not the style.
> In the OP's case, class="amount" or something else indicative of numeric
> content would be more suitable.
>

Normally *I* would, like I have a class "bucks" for formating my
currency cells, but A) I did not know what the OP's purpose for his
right aligned cells since he did not supply a URL and B) If a made one
up, it might confuse the OP so I chose a very clear demo label

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


All times are GMT. The time now is 07:04 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.