4
<mat-card id="card">
<mat-card-title>
    login
</mat-card-title>

<mat-card-content>
    
    <mat-form-field>
        <input matInput placeholder="email">
    </mat-form-field><br/>

    <mat-form-field>
        <input matInput placeholder="password">
    </mat-form-field><br/>
        <button mat-raised-button color="primary" style="margin-right:5px;">login</button>
        <button mat-raised-button color="primary" style="margin-right:5px;">register</button>  

</mat-card-content>

I tried this:

display: block;
margin: auto;

but its now working, any help would be appreciated. I'm new to angular styling

Image

Community
  • 1
  • 1
pat mat
  • 45
  • 1
  • 4

3 Answers3

3

Simply use this case

mat-card {text-align: center}

And if you want to set heading in left then use this also.

mat-card-title { text-align: left }
Piyush Jain
  • 1,895
  • 3
  • 19
  • 40
1

use style="text-align: center;"

I have create a demo on Stackblitz

<mat-card id="card" style="text-align: center;"><mat-card>
Krishna Rathore
  • 9,389
  • 5
  • 24
  • 48
1

With @angular/flex-layout it can be done by using fxLayout="row" (or column) and fxLayoutAlign="center" attributes as follow:

<mat-card fxLayout="column" fxLayoutAlign="center">
  // Your content here  
</mat-card>
H S W
  • 6,310
  • 4
  • 25
  • 36