【发布时间】:2019-03-18 22:38:42
【问题描述】:
我正在使用有棱角的材料来展示一张卡片, 我希望卡片内的内容水平居中, 即使我添加了`justify-content: flex-start;它不会使卡片内的内容相互水平,它总是粘在左边
这是我的 HTML
<!-- Classes main-div and example-card are categorised in .css file -->
<div class="main-div">
<mat-card class="example-card">
<mat-card-header>
<div class="login-box-header">
<!-- Src image is temporary hosted in image.ibb-->
<img src="https://image.ibb.co/hDqa3p/codershood.png">
</div>
</mat-card-header>
<mat-card-content>
<form>
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Username" [(ngModel)]="username" name="username" required>
</mat-form-field>
</td>
</tr>
<tr>
<td><mat-form-field>
<input matInput placeholder="Password" [(ngModel)]="password"type="password" name="password" required>
</mat-form-field></td>
</tr></table>
</form>
<mat-spinner [style.display]="showSpinner ? 'block' : 'none'"></mat-spinner>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button (click)="login()" color="primary">Login</button>
</mat-card-actions>
</mat-card>
</div>
这是我的 CSS 文件:
.example-card {
display: flex;
justify-content: flex-start;
flex-direction: column;
}
.main-div{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
我正在使用有角度的材料,角度。
如何让卡片内的内容居中?
谢谢
【问题讨论】:
-
你能在stackblitz.com上创建一个小角度应用吗
标签: html css angular flexbox angular-material