Currently, I'm working on creating a grid of boxes using CSS and jQuery, but I'm facing an issue with box expansion upon click. The problem arises when the rightmost box is clicked because it doesn't have enough space to expand and ends up moving down.
You can view my page here:
Here is an image showing the problem:
Although my code gets the job done, it may not be the most aesthetically pleasing:
$('ul#products li a').click(function() {
//Reset
$('ul#products li').removeClass("marked");
$('ul#products li .product-text').hide();
var productID = $(this).attr('name');
$("#product-"+productID+"").addClass("marked");
$("#product-text-"+productID+"").show();
});
My main concern is finding a solution to ensure that the expanded box remains on its line after clicking, possibly by swapping positions with the previous box or utilizing a plugin. Can anyone provide guidance on this matter?