How to realize the irregular layout and arrangement of pictures on HTML pages

to make a mall page, you need such a typesetting layout to show div, similar to this wasp site. Automatically maintain the same distance according to the size of the picture. I know it is adjusted by top left. But how to write a js algorithm control.
http://woofeng.cn/

Mar.12,2021

http://raphamorim.io/waterfal.


all the pictures are with fixed width and height change , which is actually waterfall flow layout . There are many solutions in Google

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaa1c1-1faf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaa1c1-1faf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?