Is it possible to mix card of different sizes within a card-group in Bootstrap 4. I want to have a large card (double width) on the left size, and two smaller cards on the right, with the same height of all three.
<div class="container">
<div class="row">
<div class="card-group">
<div class="card col-md-6">
<div class="card-block">
<h4 class="card-title">Card 1</h4>
<p class="card-text">Text 1</p>
</div>
</div>
<div class="card col-md-3">
<div class="card-block">
<h4 class="card-title">Card 2</h4>
<p class="card-text">Text 2</p>
<p class="card-text">More text 2</p>
<p class="card-text">More text 2</p>
</div>
</div>
<div class="card col-md-3">
<div class="card-block">
<h4 class="card-title">Card 3</h4>
<p class="card-text">Text 3</p>
</div>
</div>
</div>
</div>
</div>
I think the intention is that card groups are equal width and height(http://v4-alpha.getbootstrap.com/components/card/#groups), but you could override the default Bootstrap behavior to make it work like this..
http://codeply.com/go/4WVwRBTyTP
Note: Wildcard CSS selectors like this are slow. It would be better to add a special CSS class to override the Bootstrap
float:left
behavior of the columns in yourcard-group
UPDATE
Now that BS4 has flexbox, the extra CSS is no longer required. Just make the
card-group
androw
the same div, and then usecol-*
as normal to set width. However, usingcard-group
will prevent responsive column wrapping.http://www.codeply.com/go/jzIcjyg6Xa
See also https://stackoverflow.com/a/35627731/1596547, as already explained by @Skelly the predefined grid classes (
col-md-*
) do not only set thewidth
by also afloat
.Instead of using the grid classes you can also apply the
width
directly:The Bootstrap 4.1 documentation for card layout currently states:
However, as Zim's answer pointed out, card-groups are now flexbox. Therefore, you can also override the
flex-grow
style to set relative card sizes.Codeply