我有一张席子表来显示价格和持续时间之间的相关性,可以在其中编辑字段。当前的HTML如下所示:
<table mat-table [dataSource]="item.durations_array">
<ng-container matColumnDef="duration">
<mat-header-cell *matHeaderCellDef> Duration </mat-header-cell>
<mat-cell *matCellDef="let element; index as i">
<mat-form-field floatLabel="never">
<input
matInput
placeholder="Duration"
disabled="{{ !isEditing }}"
[value]="item.durations_array[i]"
[(ngModel)]="item.durations_array[i]"
/>
</mat-form-field>
</mat-cell>
</ng-container>
<ng-container matColumnDef="price">
<mat-header-cell *matHeaderCellDef> Price </mat-header-cell>
<mat-cell *matCellDef="let element; index as i">
<mat-form-field floatLabel="never">
<input
matInput
placeholder="Price"
disabled="{{ !isEditing }}"
[value]="item.prices_array[i]"
[(ngModel)]="item.prices_array[i]"
/>
</mat-form-field>
</mat-cell>
</ng-container>
<tr mat-header-row *matHeaderRowDef="['duration', 'price']"></tr>
<tr mat-row *matRowDef="let element; index as i; columns: ['duration', 'price']"></tr>
</table>
问题是,当我希望它们并排放置时,这些列会像这样彼此堆叠:
我试图将display: block
包括到表和单元格中,但是没有显示效果。通过禁用表上的flexbox,可以在检查器中获得一些结果,但是我认为display:block
会执行相同的操作吗?
通过Eliseo的评论修复,我忘记了标题和单元格定义。这是工作代码: