I want to create a boostrap ‘card’ of 3 identical cards per row and of course x amount of rows. I tried with the following and spent 3 hours and failed.
$.getJSON("./listings.php", function(e) {
$.each(e, function(i, e){
if (e.id != "") {
//create table here
var html = '<div class="card-deck mb-3 text-center">'; // this opens the row
//here are the three columns
html += '<div class="card mb-4 box-shadow" style="background-image:url(./'+e.img+');background-size:330px; auto;background-repeat:no-repeat; background-position:center;">';
html += '<div class="card-header" style="background-color: #5bc0de;">';
html += '<h4 class="my-0 font-weight-normal">'+e.status+'</h4>';
html += '</div>';
html += '<div class="card-body">';
html += '<h1 class="card-title pricing-card-title"> </h1>';
html += '<ul class="list-unstyled mt-3 mb-4">';
html += '<li> </li>';
html += '<li> </li>';
html += '<li> </li>';
html += '<li> </li>';
html += '<li> </li>';
html += '<li> </li>';
html += '<li> </li>';
html += '</ul>';
html += '<button type="button" id="'+e.id+'" class="community btn btn-block btn-outline-primary">Visit Platform</button>';
html += '</div>';
html += '</div>';
//end of 3rd column
html += '</div>'; //this closes the row
$('.community_listing').append(html); //this is just an empty div to host the rows
}
})
});
🙁
2
Answers
The best option is that you can set the wrapper as
flex
. So it will display your cards with device width. and will be auto responsive.Let me know if you want to strictly show 3 cards per row. I will edit my answer according to it.
You can also check the working fiddle here.
I think I understand your question now. You want the cards to have the same height, which is why you use card-decks.
For the example, I have overwritten the variable "data" for testing and commented out the JSON query. I hope this can help you.