How do you right-justify text in an HTML textbox?

前端 未结 3 1906
礼貌的吻别
礼貌的吻别 2020-12-29 19:17

I have a need to display many numerical values in columns. These values need to be easily editable so I cannot just display them in a table. I am using textboxes to display

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 19:55

    Did you try setting the style:

    input {
        text-align:right;
    }
    

    Just tested, this works fine (in FF3 at least):

    
        
            Blah
            
        
        
            
        
    
    

    You'll probably want to throw a class on these inputs, and use that class as the selector. I would shy away from "rightAligned" or something like that. In a class name, you want to describe what the element's function is, not how it should be rendered. "numeric" might be good, or perhaps the business function of the text boxes.

提交回复
热议问题