繁体   English   中英

如何制作相同尺寸的 Angular mat-card 列表

[英]How to make a list of Angular mat-card same size

我正在 Angular 中渲染一个 asdfasd 列表,但是我上传的图像大小不同,这导致某些 asdfasd 比其他的大。 如何使它们的大小相同?

这是 HTML

<div class="cardList">
    <ng-container *ngFor="let card of comics">
        <mat-card class="example-card">
            <mat-card-content>
                <mat-card-header>
                    <div mat-card-avatar class="example-header-image"></div>
                    <mat-card-title>{{card.name}}</mat-card-title>
                </mat-card-header>
                <img mat-card-image [src]="card.picture">
                <mat-card-content>
                    <p>
                        {{card.description}}
                    </p>             
                </mat-card-content>
                <mat-card-actions>
                    <button mat-raised-button color="primary" (click) = "openDialog(card)">${{card.amount}}</button> 
                </mat-card-actions>
            </mat-card-content>
        </mat-card>
    </ng-container>
</div>
<mat-divider></mat-divider>

这就是我得到的

试试这个

mat-card img{
  object-fit: cover; /*this makes the image in src fit to the size specified below*/
  width: 100%; /* Here you can use wherever you want to specify the width and also the height of the <img>*/
  height: 80%;
}

参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM