html - 如何制作相同大小的Angular mat-card列表
问题描述
我正在 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%;
}
推荐阅读
- algorithm - 如何使用 ANSI X9.8 加密银行帐号
- css - 我不知道为什么我的刻度在手机上是灰色的
- jsf - 我如何选择 SelectOneMenu 中默认显示的值
- firebase - 动态链接 Firebase
- asp.net-core - 如何使用 ILogger 在我的 ASP.NET Core 应用程序的 nuget 包中记录 serilog 发出的消息
- vue.js - vue.js 路由器 NavigationDuplicated 用于查询更改
- highcharts - Highcharts - yAxis 对数刻度和 allowDecimals 设置为 false 似乎没有任何效果
- spring-boot - 在外部tomcat上调用@GetMapping“/”会引发错误-Spring Boot
- java - 使用proguard构建应用程序时出现Android异常
- spring - JPA stream() 会导致 OutOfMemoryError 吗?