I need a masonry grid like this:
Is this possibile to achieve that using flexbox only? Or any other way? Don't want to use Masonry library or other library or framework.
I need a masonry grid like this:
Is this possibile to achieve that using flexbox only? Or any other way? Don't want to use Masonry library or other library or framework.
I believe CSS grid would be your friend here.
CSS Grid layout brings a two-dimensional layout tool to the web, with the ability to lay out items in rows and columns. CSS Grid can be used to achieve many different layouts. It excels at dividing a page into major regions, or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives.
Like tables, grid layout enables an author to align elements into columns and rows. However, unlike tables, grid layout doesn't have content structure, therefore enabling a wide variety of layouts not possible in tables.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
Here's a fun and simple game to help you learn and understand CSS grids.
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<section class="pad-40 " style="background-color: #f1f1f1;height: 546px">
<div class="container">
<div class="row">
<div class="col-md-8">
<img src="https://dummyimage.com/600x220/aaa/fff" width="100%">
</div>
<div class="col-md-4">
<img src="https://dummyimage.com/400x600/aaa/fff" width="100%">
</div>
<div class="col-md-4" style="top: -222px;">
<img src="https://dummyimage.com/400x255/aaa/fff" width="100%">
</div>
<div class="col-md-4" style="top: -222px;">
<img src="https://dummyimage.com/400x255/aaa/fff" width="100%">
</div>
<div class="col-md-4 ">
</div>
<div style="clear:both;"></div>
</div>
</div>
</section>
</body>
</html>