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

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

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

\"enter

UPD. As you

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 11:33

    Another possible solution is to use media queries. In our case, we have roughly the same number of columns in every table. So, just change the right padding based on screen size to give the desired right/center alignment:

    @media (min-width: 769px)
    {
       td
       {
          &.financial
          {
             padding-right: 5px;
          }
       }
    }
    
    @media (min-width: 1100px)
    {
       td
       {
          &.financial
          {
             padding-right: 20px;
          }
       }
    }
    
    @media (min-width: 1400px)
    {
       td
       {
          &.financial
          {
             padding-right: 30px;
          }
       }
    }
    

提交回复
热议问题