angular - Material Angular 卡片展示

标签 angular angular-material angular-flex-layout

我有一个图片库,我想在一个基于宝丽来卡片的系统中显示它们,该系统跨越多行和多列。我面临的问题与图像的布局有关。当图像既是纵向图像又是横向图像时,横向图像的 mat-card 属性会膨胀以匹配纵向图像的大小。我怎样才能拥有一个自然填充系统,其中垫​​卡可以适应图像的宽度/高度比?

HTML:

    <div fxLayout="row">
        <div layout="column">
            <div fxFlex="100" fxFlexOffset="1" fxLayoutWrap fxLayoutGap="2rem" class="mat-elevation-z0" *ngIf="postcards != null">
                <mat-card *ngFor="let postcard of postcards let index = index" >
                        <img mat-card-image src="{{postcard.img}}" alt="{{postcard.postcard_id}}" class="postcards" (click)="display_postcard(index)">
                </mat-card>
            </div>
        </div>
    </div>

CSS:

    .postcards {
        max-width: 320px;
    }

当前 View : You can see how the container for each landscape card gets expanded to match the height of the portrait one (not what I would like to achieve)

这就是我想要实现的目标: enter image description here

谢谢!

最佳答案

我认为您正在寻找的是 fxLayoutAlign 属性。

尝试将 fxLayoutAlign="start start" 添加到您的 div 中,如下所示:

<div fxFlex="100" fxFlexOffset="1" fxLayoutWrap fxLayoutGap="2rem" fxLayoutAlign="start start" class="mat-elevation-z0" *ngIf="postcards != null">

附言查看Flex-Layout Demo如果您想尝试不同的选择。

关于angular - Material Angular 卡片展示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47471780/

相关文章:

java - Post请求中传递文件和Json数据

html - 按钮相对于内容的位置

html - 使用具有 Angular Material 和 Flex Layout 的语义 HTML

angular - 使用 Angular 2 中的 Flex Box CSS 调整 XS 屏幕尺寸上的垫表

angular - 使用服务 worker 构建一个 Angular 应用程序以在子目录中使用

angular - ngrx/data 实体数据服务

Angular 12 中 Iframe 中 src 属性的 DomSanitizer 问题。动态设置源总是抛出错误

angular - 当用户单击 mat-calendar 中的月份导航时,如何检索月份和年份值?

angularjs - 以 Angular 选择项目后保持菜单打开

angular - 如何使用带有自定义断点的 Angular Flex ngClass?