I've created a responsive form using angular material and flex-layout. It is working fine on desktop and ipad screens.
For mobile devices, I'd like to align the form fields to the center and add a margin to the left and right of the screen. Is there a way to do it in flex-layout?
If not how can it be done with custom CSS using ngClass.xs
? I've tried setting the width to 90% but it's not centered properly and look odd.
<div class="container" fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="2%" fxLayoutAlign="center">
<mat-form-field appearance="standard" fxFlex="22%" fxFlex.xs="90%">
<mat-label>Field 1</mat-label>
<input matInput placeholder="Field 1">
<mat-icon matSuffix>place</mat-icon>
</mat-form-field>
<mat-form-field appearance="standard" fxFlex="22%" fxFlex.xs="90%">
<mat-label>Field 2</mat-label>
<input matInput placeholder="Field 2">
<mat-icon matSuffix>business</mat-icon>
</mat-form-field>
<mat-form-field appearance="standard" fxFlex="22%" fxFlex.xs="90%">
<mat-label>Field 3</mat-label>
<input matInput placeholder="Field 3">
<mat-icon matSuffix>send</mat-icon>
</mat-form-field>
<mat-form-field appearance="standard" fxFlex="22%" fxFlex.xs="90%">
<mat-label>Field 4</mat-label>
<input matInput placeholder="Field 4">
</mat-form-field>
</div>