Dynamically building a grid like structure

Hi Everyone -

I wanted to show some images in a sort of a matrix form, lets say 3 columns in each row. The images will be added and deleted based upon user actions and the matrix/grid should automatically get updated accordingly. For example, when I start adding image, it should get to the first row and first column. As I keep adding them, they should be displayed as 3 images in a row and go to the next row automatically when I add 4th image, and so forth.

I am pretty new to Ionic. Was looking at the Grid CSS feature where we can specify the rows and columns to form the grid like structure, but could not find how to limit the column numbers and then how to dynamically add and remove images to it.

This should be very similar to adding rows and columns to a html table using java script function in terms of plain html and javascript, but I am not really sure what is the best way to achieve it in Ionic.

Any reference to any existing codepen or any other pointer will be very helpful.

Thanks very much!