【问题标题】:How to make a list of Angular mat-card same size如何制作相同大小的Angular mat-card列表
【发布时间】:2020-07-07 11:30:36
【问题描述】:

我正在 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>

【问题讨论】:

    标签: html css angular


    【解决方案1】:

    试试这个

    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%;
    }
    

    Reference

    【讨论】:

    • 但这是我的css...我可以把你说的代码放在哪里? ibb.co/kKWz6Pz
    猜你喜欢
    • 1970-01-01
    • 2019-06-16
    • 2018-04-17
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-24
    • 1970-01-01
    相关资源
    最近更新 更多