首页 > 解决方案 > 在 Bootstrap-vue 中限制卡片组中的卡片数量

问题描述

我想将每行的卡片数量限制为 4,但卡片不断压缩到每行大约 10 多张卡片。我尝试使用引导容器,但没有成功。

<b-container >
<b-row align-v = "center" order-xl>
<b-card-group deck>
<b-card v-for= "ids in info" v-bind:key="ids"
:title="ids.name"
:img-src="ids.images.xs" 
style="max-width: 20rem;"
min-cols = 3   
>
<b-card-text>
  <h5>

.....
 </h5>
</b-card-text>
</b-card>
</b-card-group >
</b-row>
</b-container>

</div>

标签: vuejs2bootstrap-vue

解决方案


您应该为卡片设置一个 min-width 属性:

<b-card v-for= "ids in info" v-bind:key="ids"
:title="ids.name"
:img-src="ids.images.xs" 
style="max-width: 20rem;"
class="mw-25"
min-cols = 3   
>
<b-card-text>
  <h5>

.....
 </h5>
</b-card-text>
</b-card>

mw-25是将最小宽度设置为 25% 的引导类。


推荐阅读