How to add margin with Angular Flex Layout?

Christian picture Christian · Jan 8, 2018 · Viewed 21.8k times · Source

How can I add margin or padding to a container when using the Flex Layout Module?

Template:

<div class="container">
  hell
  <div fxLayout="column" fxLayoutAlign="center center">
    <mat-card fxFill>Simple card test</mat-card>
  </div>
</div>

Style:

.container{
    margin: 60px;
}

I noticed it doesn't seem to be adding the correct amount of margin. You'll be able to see in the screenshot, the flex container has less margin than the text outside of it.

enter image description here

Answer

aksjer picture aksjer · Jul 31, 2018

You can use multiple flexbox container for that.

See fxLayoutGap too : https://github.com/angular/flex-layout/wiki/fxLayoutGap-API