I am looking to design an HTML and CSS layout that displays items in rows, with each item expanding to load more content when clicked. Similar to the example shown below:
Desktop view grid:
The challenge arises in maintaining the layout for mobile viewing, which requires a different order of HTML elements:
Mobile view:
Currently, I have created this HTML code using Bootstrap CSS:
<div class="container">
<div class="row">
<div class="col-md-4 item">
<a class="link" href="#emp_more_4" data-id="4">
</a>
</div>
...
</div;>
</div;>
The "emp_info" elements contain additional content for each item.
And here is the jQuery code snippet used:
jQuery('.employees a').click(function() {
var id = jQuery(this).data("id");
jQuery('.employees .emp_info').hide();
jQuery('.employees #emp_more_'+id).show();
});
Although it successfully loads more content for each item, it disrupts the grid layout of columns and rows. Any suggestions on how to maintain the layout consistency for both desktop and mobile views are appreciated. I am open to exploring styling solutions without relying on Bootstrap classes if there are better alternatives.