Bootstrap 4卡组中不同大小的卡 [英] Cards with different sizes in Bootstrap 4 card-group

查看:137
本文介绍了Bootstrap 4卡组中不同大小的卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Bootstrap 4的卡组中混合使用不同大小的卡.我想在左侧使用一张大卡(双倍宽度),在右侧使用两张较小的卡,高度相同.全部三个.

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..

.card-group [class*='col-'] {
  float:none;
}

http://codeply.com/go/4WVwRBTyTP

注意:像这样的通配符CSS选择器很慢.最好添加一个特殊的CSS类来覆盖card-group

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 your card-group

更新

现在BS4具有flexbox,不再需要额外的CSS.只需将card-grouprow设为相同的div,然后照常使用col-*设置宽度.但是,使用card-group会阻止响应列换行.

Now that BS4 has flexbox, the extra CSS is no longer required. Just make the card-group and row the same div, and then use col-* as normal to set width. However, using card-group will prevent responsive column wrapping.

http://www.codeply.com/go/jzIcjyg6Xa

这篇关于Bootstrap 4卡组中不同大小的卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆