首页 > 解决方案 > mat-grid-list 的垂直对齐方式

问题描述

我正在使用角度 6.0.9

我想创建一个非常简单的布局:

这是我的布局的样子:

<mat-tab-group>
    <mat-tab>
        <ng-template mat-tab-label>View items</ng-template mat-tab-label>
        <!-- This list is for the 2 columns layout -->
        <mat-grid-list  cols="2" rowHeight="1:1" gutterSize="0">
            <!-- Firt column: the list of items -->
            <mat-grid-tile>
                <!-- Just to have some fancy borders around the item list, I put it in a mat-card -->
                <mat-card>
                    <!-- List of items -->
                    <mat-list>
                        <mat-list-item *ngFor="let item of items">
                            ...
                        </mat-list-item>
                    </mat-list>
                </mat-card>
            </mat-grid-tile>
            <!-- Second column: selected item details -->
            <mat-grid-tile>
                <!-- The details of the item -->
                <mat-card>
                    ...
                <mat-card>
            </mat-grid-tile>
        </mat-grid-list>
    </mat-tab>
    <mat-tab>
        <ng-template mat-tab-label>Create item</ng-template mat-tab-label>
        ...
    </mat-tab>
</mat-tab-group>

截屏:

截屏

我只有以下 CSS,width: 100%否则我添加了卡片不占用整个列宽。

mat-card {
    width: 100%;
}

我有两个问题:

我尝试在 CSS 和特定于材质的标签中添加layout-alignmdc-layout-grid-cell-align几乎无处不在。没有成功。

标签: angularangular-material2

解决方案


推荐阅读