如何在角材料4中心对齐卡?

Shr*_*air 6 angular-material2 angular

我创建了一个带有角度材料的角度4应用示例.我正试图将卡片放在视图中心.但它不起作用.Below是代码

app.component.html

<!--The content below is only a placeholder and can be replaced.-->
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

login.component.html

<div  ng-cloak=""  layout-fill layout="column" style="background:green" layout-align="center">
    <div flex="50" layout="row" layout-align="center">
      <md-card flex="50"></md-card>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

login.component.ts

import { Component, OnInit } from '@angular/core';
import { MdCardModule,MdInputModule } from '@angular/material';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}
Run Code Online (Sandbox Code Playgroud)

Neh*_*hal 21

添加一个类到这样的md-card东西:

.center{
  width: 75%;
  margin: 10px auto;
}

.main-div{
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<div class="main-div">
  <md-card class="z-depth center" flex="50" >Simple card</md-card>
</div>
Run Code Online (Sandbox Code Playgroud)

演示