I'm using ReactJS and iterating through an array and generating a bootstrap card for every object in the array but the cards start at the far left of the screen and they fill in left to right until they hit 5 and then creates a new row.
I would like to see if there is a way to make the first card, if there is only one, start in the center of the screen, and then populate outward as more cards get added.
Is something like that possible?
<div className='row mt-lg-3 row-cols-xs-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-5 g-4'>
{viewElements.map((element) => (
<ElementItem key={element._id} element={element} />
))}
</div>
This is how it currently looks when there are 5 cards, and it will start on the next row. I like how that looks but when there are fewer than 5 I want them to begin populating in the center of the page, not from left to right, like the second photo shows.
<section className='mt-3'>
{viewElements ? (
<div className='row mt-lg-3 row-cols-xs-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-5 g-4'>
{viewElements.map((element) => (
<ElementItem key={element._id} element={element} />
))}
</div>
) : (
<div className='container mt-5'>
<div className='content mt-5'>
<div className='row'>
<div className='row'>
<h3>No Elements To Display</h3>
</div>
</div>
</div>
</div>
)}
</section>