我有一张使用棱角材料设计的登录卡,每当我在页面上运行它时,内容都会粘在页面的左侧。
我尝试使用 flex
并使用 layout-align="center center"
但我仍然无法将卡片置于页面中央
我究竟做错了什么 ?
这是我的 html:
<mat-card class="example-card" layout="row" layout-align="center center">
<mat-card-header>
<div class="login-box-header" layout="row" layout-align="center center">
<img src="https://image.ibb.co/hDqa3p/codershood.png">
</div>
</mat-card-header>
<mat-card-content>
<form class="example-form">
<table class="example-full-width" cellspacing="0">
<tr>
<td>
<mat-form-field class="example-full-width">
<input matInput placeholder="Username" [(ngModel)]="username" name="username" required>
</mat-form-field>
</td>
</tr>
<tr>
<td><mat-form-field class="example-full-width">
<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>
这里的内容仍然没有居中:
原文由 Chief Madog 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用非常简单的 Flex 修复它
并用一个类包装所有东西