【发布时间】:2020-01-28 19:09:36
【问题描述】:
我在列中使用 Bootstrap Vue 库,我每行显示 3 张卡片,它在桌面上看起来不错,但在移动设备上看起来太小了,所以我想在移动设备上显示这 3 张卡片一张在另一张下方。我该怎么做?
new Vue({
el: "#app"
});
.card{
background-color: #BAE5FF !important;
border: none !important;
border-radius: 0px 0px !important;
}
.work-link{
color: #172e54;
}
<link href="https://unpkg.com/bootstrap@4.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-vue@2.0.0-rc.11/dist/bootstrap-vue.css" rel="stylesheet"/>
<script src="https://unpkg.com/vue@2.5.17/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.0.0-rc.11/dist/bootstrap-vue.min.js"></script>
<div id="app">
<b-row>
<b-col cols="4" sm="4" md="4">
<b-card no-body style="max-width: 20rem;" img-src="https://placekitten.com/380/200" img-alt="Image" img-top>
<template v-slot:header>
<a href="" class="work-link text-center"><h5 class="mb-0"><strong>1</strong></h5></a>
</template>
</b-card>
</b-col>
<b-col cols="4" sm="4" md="4">
<b-card no-body style="max-width: 20rem;" img-src="https://placekitten.com/380/200" img-alt="Image" img-top>
<template v-slot:header>
<a href="" class="work-link text-center"><h5 class="mb-0"> <strong>2</strong></h5></a>
</template>
</b-card>
</b-col>
<b-col cols="4" sm="4" md="4">
<b-card no-body style="max-width: 20rem;" img-src="https://placekitten.com/380/200" img-alt="Image" img-top>
<template v-slot:header>
<a href="" class="work-link text-center"><h5 class="mb-0"><strong>3</strong></h5></a>
</template>
</b-card>
</b-col>
</b-row>
</div>
【问题讨论】:
-
列属性 sm, md, lg, xl 表示在各个断点处,每行可能有 12 个列中您希望使用的列数。所以,如果你想在断点 sm 处设置三个等宽的列,你可以使用
。特殊值 auto 可用于占用一行中剩余的可用列空间。 -
这不是我想要的,我想要的是在移动视图中将每张卡片显示在另一张下方,但在桌面的同一行中仍然显示 3 张卡片,所以使用 sm md lg 没有'不要为我做任何事,即使我使用例如 sm="12" md="4" lg="4".
-
sm="1" 也许更合适?
-
哎呀,还是不行:(
标签: vue.js bootstrap-vue