Skip to content Skip to sidebar Skip to footer

How To Create A Masonry Layout Using Bootstrap 4?

I'm trying to achieve this: Using Bootstrap 4, Js,Css and obviously HTML. I did not succeed to find something similar on SO, but I found this on the Bootstrap 4 documentation, bu

Solution 1:

As @Yan said you can use .card-columns to archive a Masonry layout, you can find more information in the Boostrap 4 docs.

There's how the code should look:

<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB"crossorigin="anonymous"><divclass="container"><divclass="card-columns"><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/450x350"alt="Card image cap"></div><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/150x150"alt="Card image cap"></div><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/250x150"alt="Card image cap"></div><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/250x150"alt="Card image cap"></div><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/150x150"alt="Card image cap"></div><divclass="card"><imgclass="card-img"src="http://via.placeholder.com/350x150"alt="Card image cap"></div></div></div><scriptsrc="https://code.jquery.com/jquery-3.3.1.slim.min.js"integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"crossorigin="anonymous"></script><scriptsrc="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"crossorigin="anonymous"></script>

Solution 2:

Bootstrap Cards can be organized into Masonry-like columns with just CSS by wrapping them in .card-columns.

Check this working masonry code with cards!

<divclass="card-columns"><divclass="card">
               Card 1
            </div><divclass="card">
              Card 2
            </div><divclass="card">
               Card 3
            </div></div>

Post a Comment for "How To Create A Masonry Layout Using Bootstrap 4?"