JS: Horizontal Masonry Gallery Snippet
<div class="gallery-row"> <img src="..."> <img src="..."> <img src="..."><div>
const rows = document.getElementByClassname('galler-row');const makeRow = el => { let r = 0; let images = []; el.childNodes.forEach(element => { if (element.nodeName == 'IMG') { images.push(element); element.addEventListener('load', () => { const ratio = element.naturalWidth / element.naturalHeight; element.setAttribute('data-ratio', ratio); r += ratio; resize(r, images); }); } });};const resize = (r, images) => { images.forEach(img => { let ratio = img.getAttribute('data-ratio'); img.style.width = `${(ratio / r) * 100}%`; });};rows.foreach(row => makerow(row))