Skip to content

Instantly share code, notes, and snippets.

@tarikguney
Last active September 30, 2023 11:22
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tarikguney/83cdae881f74b1addce8f3236f503379 to your computer and use it in GitHub Desktop.
Save tarikguney/83cdae881f74b1addce8f3236f503379 to your computer and use it in GitHub Desktop.
Login Form Design in Angular Material
.login-form-flex {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.button-flex-container {
display: flex;
width: 100%;
justify-content: flex-end;
}
<div class="login-form-flex">
<mat-card>
<mat-card-title>
Login
</mat-card-title>
<mat-card-content>
<mat-form-field>
<input matInput placeholder="User Name">
</mat-form-field>
<br/>
<mat-form-field>
<input type="password" matInput placeholder="Password"/>
</mat-form-field>
</mat-card-content>
<mat-card-actions>
<div class="button-flex-container">
<button mat-raised-button color="primary">Login</button>
</div>
</mat-card-actions>
</mat-card>
</div>
@tarikguney
Copy link
Author

The CSS uses FlexBox properties to align content. The login form is centered in the screen both horizontally and vertically.

The following shows how the login looks like in a browser:

image

@Gaga-for-coding
Copy link

Very useful thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment