angular - 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%;
}
我有两个问题:
首先,列在页面中垂直居中。也就是说,项目列表的卡片和项目详细信息的卡片不在选项卡的正下方,而是位于页面中间。
其次,我真的不明白我应该如何使用有角度的材料。在比较材料与角度/材料的文档时,我看到材料具有“mdc-layout-grid-cell-align”,但我不知道在使用材料/角度时如何使用它!
我尝试在 CSS 和特定于材质的标签中添加layout-align
或mdc-layout-grid-cell-align
几乎无处不在。没有成功。
解决方案
推荐阅读
- python - 从列表中弹出并从函数中减去(Hangman)
- if-statement - 如何在詹金斯脚本化管道作业中使用布尔参数编写条件步骤?
- ios - iOS WKWebView 检测何时到达底部
- java - onTouchListener 不接受布局
- javascript - 如何插入背景图像以响应整个屏幕?
- android - 离线用户能否在 Firebase 实时数据库中执行特定于其 uid 的数据库事务?
- c# - 在 Visual Studio 2017 中加载机器人框架模板
- firebase - Flutter Firestore 如何从聊天对话中获取最后一条消息?
- python-3.x - tkinter 窗口未正确关闭
- android - (未设置)显示在 Firebase Analytics 仪表板上