Looking to implement a grid/list view using bootstrap 4 cards.
<div class="well well-sm">
<strong>Display:</strong>
<div class="btn-group">
<a href="#" id="list" class="btn btn-default btn-sm"><span class="fas fa-list-ul"></span>List</a>
<a href="#" id="grid" class="btn btn-default btn-sm"><span class="fas fa-th-large"></span>Grid</a>
</div>
</div>
Jquery implementation:
$('#list').click(function(event){
event.preventDefault();
$('.card-deck').addClass('list-group-item');
$('.card-deck').removeClass('grid-group-item');
$(this).addClass('active');
$('#grid').removeClass('active');
});
$('#grid').click(function(event){
event.preventDefault();
$('.card-deck').removeClass('list-group-item');
$('#list').removeClass('active');
$(this).addClass('active');
$('.card-deck').addClass('grid-group-item');
});
Referenced code from another post: Bootstrap 4 card/panel with image left of header and title
<div class="card">
<div class="row no-gutters">
<div class="col-auto">
<img src="//placehold.it/200" class="img-fluid" alt="">
</div>
<div class="col">
<div class="card-block px-2">
<h4 class="card-title">Title</h4>
<p class="card-text">Description</p>
<a href="#" class="btn btn-primary">BUTTON</a>
</div>
</div>
</div>
<div class="card-footer w-100 text-muted">
</div>
</div>
Requirement is to transform the view into stacked card blocks when 'grid' is clicked:
<div class="card-deck>
<div class="card" style="width: 18rem;">
<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">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
Seeking guidance on achieving this functionality in bootstrap 4.
Thank you for your assistance.
Nabi