I want to have a few Bootstrap cards on html page. The exact number of them I don't know and cannot predict, because it depends on the user data in the database. For example, if the user has 4 items I need to create 4 cards, if 10 then 10 cards and so on. So, I create those cards dynamically with jQuery by giving them Bootstrap 4 class names. The issue is Bootstrap cards start filling in the space from left by giving equal width and height to the cards.
So, if the user has 2 items, I want to create 2 cards, with same width and height of my choice and whatever is left on that row to be blank/empty
I tried changing default card width, trying max-width, min-width. But it did not work
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
</div>
</div>
This is the default Bootstrap 4 result:
[ [ card 1 ] [ card 2 ] ]
What I want is:
[ [card 1] [card 2] [leave blank all the way to the right ] ]
Any suggestions? Thanks