I have a slider that ranges from 1 and up to 3. The slider's on change event sets the value of a CSS variable (e.g. :root { --colNum: 1 } ) so I am able to dynamically change the number of grid columns.
What I am trying to achieve is (let's say I have six images in total):
- When I have one column set, I would like to display only the first image, full size and hide the five remaining images.
- When I have two columns set, I would like to display the first four images, two in each row and hide the two remaining images.
- When I have three columns set, I would like to display all the six images, three per row.
Similar to the following images:
I have created a sandbox, tried different examples but none of them fit my needs so I have left it in an "initial state".
I am not sure if I am overthinking that but I am open to hear any suggestions or even other approaches in how I could achieve that result.
Thanks in advance.


