@mizard, not sure why it’s not working for you.
I tried the css on Mercury demo pages and it worked for all 4 different layouts (Masonry, Masonry Compact, Grid, Grid Compact).
I attached pictures of the before and after adding the css code in the DevTools of the browser.
Hope I am understanding your problem correctly — does the “after” picture shows what you are looking for?