My goal is to generate a collection of fullwidth ion-cards using data from an array of objects

I am attempting to iterate through an array of objects in order to generate a set of cards, either FULLWIDTH or halfwidth with the last one centered if the count is an odd number.

I have created a component that contains the card layout and I am using *ngFor to loop through the array. However, I am facing an issue where the column size does not change regardless of the attributes I input or their placement (inside or outside the loop). The cards are resizing dynamically based on the text content.

<ion-row>
  <app-artist-view *ngFor="let deal of loadedEvent.deals" [deal]='deal'></app-artist-view>
</ion-row>
<ion-col size = "12"> 
  <ion-card>

    <ion-item>
      <ion-label  class="ion-text-center">{{deal.title}}</ion-label>
    </ion-item>


    <ion-card-content class="ion-text-center">

      <ion-card-subtitle>Name: {{deal.talent.name}}</ion-card-subtitle>
      <ion-card-subtitle>{{deal.performanceType}}</ion-card-subtitle>
      <ion-card-subtitle>Length: {{deal.performanceLength}}</ion-card-subtitle>
      <ion-card-subtitle>Status: {{deal.status}}</ion-card-subtitle>
      <ion-card-subtitle>Value: {{deal.value}}</ion-card-subtitle>
   </ion-card-content>
  </ion-card>
</ion-col>  

The cards are adjusting in size according to the text content, rather than remaining full-width for each element.

Answer №1

To utilize flex-boxing:

.wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
}

.box {
  box-sizing: border-box;
  padding: 12px;
  height: 64px;
  flex: 0 0 calc(50% - 24px);
  background: salmon;
  border: 1px solid skyblue;
  margin: 12px;
}
<div class="wrapper">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div>

When using flexbox, it's important to calculate the width of each element considering the spacing between them. This method provides a quick solution for handling gutter space within flexed elements.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disabling Angular routerlink tabindex additions can be done by modifying the application's

While the angular guide to accessibility covers many important topics, it fails to address the issue of preventing tabindex from being added on every button with a routerlink. This has resulted in my app having tabindex="0" on buttons throughout. ...

The transparency of the navigation menu is perplexing to me. I am unclear as to the reasoning behind it. I desire a

I am currently using a pre-made WordPress theme. Recently, I incorporated particles.js as the background for my website. The issue I am facing now is that my navigation menu is blending into the same color as the background. I have tried defining a separat ...

Sending file URL to Angular component

Hey there, I am looking to relocate an existing link within my Angular 4 project. For instance, the link I want to move is "". I have attempted to do so in my router configurations: path: 'test', component: TestComponent, children: ...

Check the status when clicking on an event using Angular Material

I am working with an Angular element that involves a checkbox. <mat-checkbox class="btn-block" labelPosition="before" (change)="showOptions($event)" (click)="makeJSON($event.checked,i,j,k)"> </mat-chec ...

Ensure that the icon at the conclusion of the <p> tag remains intact and does not break off on its

Issue at hand: The clock icons on my phone screen sometimes break off, see example here: https://i.sstatic.net/NQz9i.png Preferred outcome: The icons should be intact along with the time value, like this: https://i.sstatic.net/nZmC9.png Here is the H ...

RXJS buffering with intermittent intervals

Situation: I am receiving audio data as an array and need to play it in sequence. The data is coming in continuously, so I am using an observable to handle it. Since the data arrives faster than it can be played, I want to use a buffer to store the data w ...

Incorporating Scatter Dots into a Horizontal Stacked Bar Chart using Chart.js

My horizontal stacked bar chart is not displaying pink scatter dots based on the right y axis numbers. I need help figuring out what I am doing wrong. When I change the chart to a normal bar instead of horizontal, the dots appear. However, I require them ...

Can you help me identify any issues with this code for uploading an image and quickly displaying it in Angular?

Located within the profile.component.html file <label for="profile">Profile Photo</label> <input type="file" [(ngModel)]='uploadedPhoto'/> <img [src]='uploadedPhoto'> Contained in the profile.component.ts file ...

Issues encountered when dealing with floating elements and margins

Having some difficulties with aligning elements on my website. As someone who is not highly skilled in coding, I am struggling to define the width and float properties for certain classes. Despite my attempts, it seems that the elements are not positioning ...

What is the best method for inserting a 'Placeholder' in an Angular datePicker?

Looking for assistance with placing placeholder text inside an Angular datePicker, specifically wanting to display 'From' and 'To' labels within the datePicker. datePicker I am a novice when it comes to Angular development - can someon ...

Tips on joining property name in typescript

Attempting to pass values between components using inheritance but encountering difficulties. Is it possible to achieve this through a service? If so, how can I overcome this issue? Any assistance in finding the solution would be greatly appreciated. bus. ...

Tips for positioning the popup ul in relation to its parent li

How can the pop-up ul be positioned in the center of the parent li using CSS? * { margin: 0; padding: 0; } #track-nav { margin-left: 50px; margin-top: 50px; float: left; width: 100%; list-style: none; font-weight: bold; margin-bottom: ...

Tips for eliminating the entire link from the footer section

Whenever a link is hovered over, a white box displaying the full URL appears at the bottom left of the browser. Is there a way to remove this feature from my website? I appreciate any assistance with this issue. Thank you! ...

Issue with mediaelement in Angular 8: video playback does not display after 2 seconds

I'm encountering an issue with MediaElement js when trying to play videos in .m3u8 format within a slider containing multiple videos. Whenever I click on the play button for any video, only a 2-second clip is shown before the video disappears. Any as ...

Is there a way to programmatically reselect a checkbox in Angular if it has been previously unselected?

I need to ensure that a checkbox remains checked, even if a user tries to uncheck it. I am using Angular 7 for this task. Here is a snippet of the template code: type="checkbox" [(ngModel)]="CheckBoxValue" (ngModelChange)="onChangeCheckBox(Check ...

Modify the animation attribute of the <circle> element using AngularJS

A new feature I implemented in my web app is a customizable countdown timer. As an added visual enhancement, I am now looking to create an animated circle around the timer. The animation duration will vary based on the countdown length. Here is a snippet ...

Tips for making an ajax call in Angular 6

As a backend developer, I have limited experience with Angular. How can I send an ajax request from Angular to test my API? The request needs to be sent before clearing the localeStorage. Can you provide guidance on how to achieve this? <button (clic ...

The Perfect Scrollbar feature is not functioning properly in conjunction with the accordion menu

I am having some trouble with implementing the Perfect Scrollbar alongside an accordion slider menu. The scrollbar is not working as expected, and you can view the fiddle here. On initial page load, the scrollbar only appears for the first sub-menu aft ...

Angular is reporting that the check-in component is nonexistent

I encountered an error in my Angular 8 application while working on a component. The error seems to be related to nested components within the main component. It appears that if the component is empty, the error will be shown, but if it's not null, th ...

The bootstrap modal is appearing correctly, but the content within it is not displaying properly

I've been working on a website and added a modal for signup. However, when the user clicks on the signup button, the modal appears but the content inside it is not clickable. Can someone please help me with this issue? Here is the code snippet I am us ...