【发布时间】:2020-04-09 11:46:41
【问题描述】:
我有一个垫表来显示价格和持续时间之间的相关性,可以在其中编辑字段。当前的 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 会这样做吗?
【问题讨论】:
-
你可以试试“display:block”而不是“style:block”吗?
-
抱歉,这里有错字。我使用了 display:block 但在这里写错了。已在原帖中更正
-
为什么不使用
<th mat-header-cell *matHeaderCellDef>和<td mat-cell *matCellDef="let element">? (您直接使用<mat-header-cell>和<mat-cell>) -
这就是问题所在!想知道我从哪里得到了忘记元素中的
th和td的想法
标签: html angular flexbox angular-material