How to center right-aligned numbers in table column using CSS?

前端 未结 11 2137
傲寒
傲寒 2021-02-02 10:54

The picture below illustrates what I\'m trying to accomplish:

\"enter

UPD. As you

11条回答
  •  滥情空心
    2021-02-02 11:19

    I believe the actual td in that table (if it is indeed a table) will have a fixed width, and lots of padding to give the illusion that it's centre-right-aligned.

    You could try a crude style such as this:

    /* For demonstration purposes, a fixed width `th`. */
    th.headrowrnum {
        width: 200px;
    }
    
    td.rightalignnum {
        width: 100px;
        padding: 0 50px;
        text-align: right;
    }
    

    HTML:

    >
        
    Col 1 Col 2
    X 5
    Y 500

提交回复
热议问题