简体   繁体   中英

Set ion-card at same size in a a ion-grid

Hi I am building a catalog app and I am showing some items but they are displaying at different sizes and I can-t achieve to get ion-cards to be displayed at same sizes

<ion-content [fullscreen]="true">

  <ion-grid > 
      <ion-row *ngFor = 'let item of items'>
          <ion-card>
            <ion-img  [src]='item.imagePath'></ion-img>
            <ion-header>
              <ion-card-title class='ion-text-center'> {{ item?.title }} </ion-card-title>
              <ion-card-subtitle class='ion-text-center'> {{ item?.price }} </ion-card-subtitle>
            </ion-header>
            <!-- <ion-card-content class='ion-text-wrap'> {{ item?.description }} </ion-card-content> -->
          </ion-card>
      </ion-row>

  </ion-grid>

</ion-content>

How it looks enter image description here

You need to wrap each row in a column.

<ion-grid>
 <ion-col size="12">
  <ion-row *ngFor = let item of items'>
   <ion-card>
    <ion-img  [src]='item.imagePath'></ion-img>
         <ion-header>
          <ion-card-title class='ion-text-center'> {{ item?.title }} </ion-card-title>
          <ion-card-subtitle class='ion-text-center'> {{ item?.price }} </ion-card-subtitle>
        </ion-header>
        <!-- <ion-card-content class='ion-text-wrap'> {{ item?.description }} </ion-card-content> -->
      </ion-card>
  </ion-row>
 </ion-col>
</ion-grid>

and in you CSS do this....

 ion-card{
  display: flex;
  flex-direction: column;
  width: 100% !important;
  margin: 0 !important;
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM