function resizeGridItem(item){
grid = document.getElementsByClassName("layout-classic")[0];
rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
imgHeight = item.querySelector('.featured-img').getBoundingClientRect().height
contentHeight = item.querySelector('.post-content').getBoundingClientRect().height
rowSpan = Math.ceil(((imgHeight+contentHeight)+rowGap)/(rowHeight+rowGap));
item.style.gridRowEnd = "span "+rowSpan;
}
function resizeAllGridItems(){
allItems = document.querySelectorAll(".layout-classic .post");
for(x=0;x<allItems.length;x++){
resizeGridItem(allItems[x]);
}
}
function resizeInstance(instance){
item = instance.elements[0];
resizeGridItem(item);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter