我是Flex Layout的新手,刚开始研究如何使用带有flex布局的角度材料 .
我使用角度材料在角度2中实现了一个简单的登录表单 . 我想使用带有角度材质的flex布局 .
我使用mat-card,我已经对齐了我的表单元素 . 但我想把mat-card放在我的屏幕中央 . 它是水平居中而不是垂直居中
这是我的代码
myform.component.html
<div fxlayout="column" style="background: white;">
<mat-card fxFlex>
<form (ngSubmit)="onSubmit(user.username,user.password)" #myForm="ngForm">
<p style="font-size: 30x;">Space Study</p>
<p style="font-size: 14px;">Sign In</p>
<mat-input-container class="form-row">
<span matTooltip="Username">
<input matInput placeholder=" " id="username" [(ngModel)]="user.username" name="username">
</span>
<span matPrefix><mat-icon>person </mat-icon></span>
</mat-input-container>
<mat-input-container class="form-row">
<span matTooltip="Password">
<input matInput placeholder=" " id="password" [(ngModel)]="user.password" name="gpassword" [type]="hide ? 'password' : 'text'">
</span>
<span matPrefix><mat-icon>remove_red_eye </mat-icon></span>
</mat-input-container>
<button mat-raised-button color="primary" type="submit" mat-raised-button>Login</button>
<mat-progress-bar mode="indeterminate" *ngIf="showprogressbar"></mat-progress-bar>
</form>
</mat-card>
</div>
myform.component.css
mat-card{
width: 350px;
height: 400px;
margin:auto;
vertical-align:middle;
}
.form-row{
display: flex;
}
.form-row input{
flex: 1;
}
这是我的输出窗口
请问有什么人可以告诉我如何将我的垫卡水平和垂直放置在我的屏幕中央 .
1 回答
我为你的问题创建了stackblitz .
Here is the stackblitz just I changed to the css
我添加了css .