I have created a sample angular 4 application with angular material. I'm trying to center the card in the view. But its not working.Below is the code
app.component.html
<!--The content below is only a placeholder and can be replaced.-->
<router-outlet></router-outlet>
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>
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() {
}
}
You can put style="text-align:center;" inside input element.
Try adding display: inline-block !
Add a class to the md-card
something like this:
.center{
width: 75%;
margin: 10px auto;
}
.main-div{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
html:
<div class="main-div">
<md-card class="z-depth center" flex="50" >Simple card</md-card>
</div>
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With