'How to create masonry layout but the flow will be from left to right?

I watched tons of videos for building masonry layout in CSS - something like pinterest. For example this

https://www.youtube.com/watch?v=EwFH4UyaFsA&ab_channel=EnvatoTuts%2B
https://codepen.io/tutsplus/pen/KKMdjVQ

every video tutorial implementation has grid columns so when we have images for example 1,2,3,4,5

i need the image direction to go from left to right so

1 2 3
4 5

but on all tutorials it is from top to bottom

1 3 5
2 4

can this even be solved ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source