【发布时间】:2020-09-08 03:11:07
【问题描述】:
我在 Angular 应用程序中使用 Angular Material 和 Angular Flex-Layout,但在移动设备上显示文本时遇到问题。正如你在小碎石上看到的那样,那里的标签被剪掉了。如果在移动设备上,我将如何显示它没有被剪切或者我认为另一列应该堆叠在下面? 检查下面的这张图片以获取当前输出。还有没有一种有效的方法来迭代标签和值而不在 html 中放置许多 div?
HTML
<mat-card-content fxLayout="row" fxLayoutAlign="stretch">
<mat-grid-list cols="6" rowHeight="28px">
<mat-grid-tile [colspan]="1" [rowspan]="4">
<div>
<div class="details" *ngFor="let label of labels">
<label><strong>{{ label.name }}</strong></label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="2" [rowspan]="4">
<div>
<div class="details">
<label>1</label>
</div>
<div class="details">
<label>Robert Williams</label>
</div>
<div class="details">
<label>robert@gmail.com</label>
</div>
<div class="details">
<label>Human Resource</label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="1" [rowspan]="4">
<div>
<div class="details" *ngFor="let label of labels2">
<label><strong>{{ label.name }}</strong></label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="2" [rowspan]="4">
<div>
<div class="details">
<label>9178384567</label>
</div>
<div class="details">
<label>Phoenix</label>
</div>
<div class="details">
<label>Male</label>
</div>
<div class="details">
<label>Aug 21, 2019</label>
</div>
</div>
</mat-grid-tile>
</mat-grid-list>
</mat-card-content>
【问题讨论】:
-
一定要使用
mat-grid-list吗?因为它迫使您拥有固定宽度的列和固定高度的行。还有其他几种(更简单的)方法可以实现图像中的布局。 -
@ysf。不,我不需要使用 mat-grid-list。我只想实现图片的外观。谢谢
标签: css angular angular-material angular7 angular-flex-layout