1

I have to display 3 cards in a single row, horizontally using *ngFor but it is getting displayed vertically. Here is the code for my mat-card.

<div fxFlex="30" *ngIf="mood">
        <mat-card *ngFor="let exercise of mood.exercises">
          <mat-card-header>
            <button mat-button mat-card-avatar><a href={{exercise.link}} target='_blank'><span class="fa fa-play fa-lg"></span></a></button>
            <mat-card-title>
              <h3>{{exercise.name | uppercase}}</h3>
            </mat-card-title>
          </mat-card-header>
          <img mat-card-image src="{{ BaseURL + exercise.image}}" alt={{exercise.name}}>
          <mat-card-content>
            <p>{{exercise.description}}</p>
          </mat-card-content>
          <mat-card-actions>
            <button mat-button>LIKE</button>
            <button mat-button>SHARE</button>
            <span class="flex-spacer"></span>
          </mat-card-actions>
        </mat-card>
   </div>

Using this code all the 3 cards are getting displayed vertically but I need to bring them horizontally . I would be really grateful if anyone could suggest the changes that I need to make. Here is the screenshot of the problem that I am facing while displaying i.e. all cards are displayed vericallyHere is the problem that I am facing while displaying i.e. all cards are displayed verically

1 Answers1

0

Use fxFlex in mat-card instead od div.

<div *ngIf="mood">
        <mat-card fxFlex="32" style="margin-left: 10px;"  *ngFor="let exercise of mood.exercises">
          <mat-card-header>
            <button mat-button mat-card-avatar><a href={{exercise.link}} target='_blank'><span class="fa fa-play fa-lg"></span></a></button>
            <mat-card-title>
              <h3>{{exercise.name | uppercase}}</h3>
            </mat-card-title>
          </mat-card-header>
          <img mat-card-image src="{{ BaseURL + exercise.image}}" alt={{exercise.name}}>
          <mat-card-content>
            <p>{{exercise.description}}</p>
          </mat-card-content>
          <mat-card-actions>
            <button mat-button>LIKE</button>
            <button mat-button>SHARE</button>
            <span class="flex-spacer"></span>
          </mat-card-actions>
        </mat-card>
      </div>
    </div>