-3

How can I make masonry grid of only 4 images that will always look like the this?

I need this alignment to be the same on every screen size and always form a square. Is this possible? I tried a lot of different approaches and nothing seems to work for all screen sizes.

Bennett
  • 867
  • 2
  • 12
  • 27

1 Answers1

0

Masonry is designed for dynamic layouts. You should probably use something more appropriate for a static grid, like CSS Grid.

Working from your own answer, I made a version a little more versatile. It uses the container width for the aspect ratio. Dependency on the device width can be limiting.

codepen.io/joeflash/pen/wxdomE

.grid-blocks {
  position: relative;
  margin: 0 auto;
  width: 80%;
  overflow: hidden;
}
JoeFlash
  • 16
  • 2
  • Yes this is great, I did the aspect ratio in my work later but I didn't update the pen. But this is better. Thank you! – user2974944 Jul 24 '18 at 05:39