I've been facing a challenge with this recently, so I've made the decision to reach out here for some assistance.
The illustration below displays my current situation. There is an ion-card (in red), containing an ion-grid (blue) with 6 ion-rows, the last two of which have 3 ion-cols each (in green).
No specific width has been set for any of the elements (apart from the ion-cols with a col-4
attribute). The final two rows are currently spanning the entire width of the ion-grid... Two things I am aiming to achieve:
I want the last two rows to adjust their width according to the content (so all cols will match the widest cell); and then, I wish to center that grid - which will now be slightly narrower than the ion-card's width - horizontally within the card. Any guidance on how to accomplish this? Thank you!
Screenshot
Below is the resulting HTML code:
<ion-card class="card card-md">
<ion-card-content class="card-content card-content-md">
<ion-grid class="grid">
<ion-row class="row">orci ut</ion-row>
<ion-row class="row">lorem ipsum dolor</ion-row>
<ion-row class="row">consectetur adipiscing </ion-row>
<ion-row class="row">tristique</ion-row>
<ion-row class="row">
<ion-col class="col" col-4="">netus</ion-col>
<ion-col class="col" col-4="">dui sollicitudin lacinia </ion-col>
<ion-col class="col" col-4="">accumsan</ion-col>
</ion-row>
<ion-row class="row">
<ion-col class="col" col-4="">Phasellus porta</ion-col>
<ion-col class="col" col-4="">bibendum</ion-col>
<ion-col class="col" col-4="">tempor eget</ion-col>
</ion-row>
</ion-grid>
</ion-card-content>
</ion-card>