我如何将页眉和垫子表中的数据更改为页面右侧?

问题描述 投票:0回答:1

我正在尝试以角度使用垫子表,所以我可以拥有一个带有数据的表,问题是表字段的标题不在右侧,但我希望它们是我使用的RTl,但是我没有用我该怎么办?这是我的桌子enter image description here

这是我的html代码

<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"  class="table"  >

    <!--- Note that these columns can be defined in any order.
          The actual rendered columns are set as a property on the row definition" -->

    <!-- Position Column -->
    <ng-container matColumnDef="position">
      <th mat-header-cell *matHeaderCellDef > NO </th>
      <td mat-cell *matCellDef="let element"> {{element.position}} </td>
    </ng-container>

    <!-- Name Column -->
    <ng-container matColumnDef="name">
      <th mat-header-cell *matHeaderCellDef> name </th>
      <td mat-cell *matCellDef="let element"> {{element.name}} </td>
    </ng-container>

    <!-- Weight Column -->
    <ng-container matColumnDef="weight">
      <th mat-header-cell *matHeaderCellDef> weight </th>
      <td mat-cell *matCellDef="let element"> {{element.weight}} </td>
    </ng-container>

    <!-- Symbol Column -->
    <ng-container matColumnDef="symbol">
      <th mat-header-cell *matHeaderCellDef> symbol </th>
      <td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
  </table>

这是CSS

 table {
        direction: rtl;
        width: 1300px;

      }
html css angular angular-material
1个回答
0
投票

这里有一个小的Stackblitz:https://stackblitz.com/edit/angular-cunndn?file=src/app/table-basic-example.html

您只需要将dir =“ rtl”添加到您的html标签中,如...

<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" dir="rtl">

© www.soinside.com 2019 - 2024. All rights reserved.