Bootstrap 5 layout for different sizes cards - like Pinterest
As explained in the Bootstrap 5 docs, the Masonry JS plugin is the recommended option for this type of "Pinterest" layout. The multi-column card layout (card-columns) that was used in Bootstrap 4 is no longer available in Bootstrap 5.
Using the Masonry plugin is easy. Just use the appropriate col-*
class to set the number of columns across, and then the data-masonry
attribute on the containing row
...
<div class="container">
<div class="row" data-masonry='{"percentPosition": true }'>
<div class="col-*">
...
</div>
</div>
</div>
https://codeply.com/p/yrjCBwUeKR
Note: The CSS grid masonry (ie: grid-template-rows: masonry;
) option mentioned by others currently only works in Firefox, and is not yet a recommended option.
Tangled cards in Bootstrap
The result you are thinking of can be achieved by integrating Masonry with the Bootstrap grid system and cards component.
Masonry is not included in Bootstrap so you have to include it manually in your system.
Include this script tag in your webpage
<script src="https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js" async></script>
After including this you have to add data-masonry='{"percentPosition": true }'
like this in the to the .row
wrapper,
<div class="row row-cols-2" data-masonry='{"percentPosition": true }'>
Output
Is it possible to create a pinterest-like layout with Bootstrap only?
Found a (free) template at http://bragthemes.com/demo/pinstrap/. It's supposed to have all you are asking for. Haven't had time to check it out, though.
Edit 2016-03-15: Bootstrap 4 allows this out of the box here. It's still in alpha, but we're getting there.
card-columns class is missing in bootstrap 5.0 ? does bootstrap provide any alternative in addition to using css media queries and flex column?
As explained in the Bootstrap 5 docs, card-columns were dropped in favor of Masonry.
"In v4 we used a CSS-only technique to mimic the behavior of
Masonry-like columns, but this technique came with lots of unpleasant
side effects. If you want to have this type of layout in v5, you can
just make use of Masonry plugin. Masonry is not included in
Bootstrap..."
Bootstrap 5 Masonry Demo
Related: Bootstrap 5 layout for different sizes cards - like Pinterest
Related Topics
How to Anti-Alias Clip() Edges in HTML5 Canvas Under Chrome Windows
Make Flex Container Take Width of Content, Not Width 100%
In Chrome 55, Prevent Showing Download Button for HTML 5 Video
How to Remove X and Y on Submit in HTML Form with Image Type Button
Making Href (Anchor Tag) Request Post Instead of Get
How to Stop <Div> Tags Interfering with Counters
Gradient Colors in Internet Explorer
CSS Sprites and Repeating Backgrounds
Poor Anti-Aliasing of Text Drawn on Canvas
Freezing/Fixing The Top Header Row of a Table
What Client-Side Web Scripting Languages Are There Other Than JavaScript and Vbscript
How to Detect Only with CSS Mobile Screens
Dashed Border Not Showing in Firefox
How to Successfully Embed Images in HTML for Display in Webmail Clients
Select Size Attribute Size Not Working in Chrome/Safari
CSS Making Two Divs Equal Height with Display Table
Random Querystring to Avoid Ie Caching
Div Element Won't Stay at The Bottom When iOS 7 Virtual Keyboard Is Present