首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使卡片内部列之间的间距变小

使卡片内部列之间的间距变小
EN

Stack Overflow用户
提问于 2020-11-09 00:40:30
回答 1查看 25关注 0票数 0

我有这个形状,想要近似每一列之间的距离,这意味着我想近似每一个蓝色部分之间的距离,我如何做that_?

Card.vue:

代码语言:javascript
复制
<template>
  <div>
    <div class="card d-inline-flex" style="width: 40rem; height:7rem; ">
      <div class="row background">
        <div class="col">
         <div class="p-5 bg-info rounded-left ">Flex item 1</div>
        </div>
        <div class="col">
          <div class="p-5 bg-info rounded-0 ">Flex item 1</div>
        </div>
        <div class="col">
          <div class="p-5 bg-info rounded-right">Flex item 1</div>
        </div>
      </div>
    </div>
  </div>
</template>    
<script></script>    
<style>
.background {
  background-color: #dcdcdc;
}
.d {
  margin-left: 4px;
}
</style>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-09 01:07:52

之所以有这个空格,是因为bootstrap预先定义了类col的padding和padding的值为15px。因此,要获得所需的空间,只需在div中添加一个自定义类,并使用padding和padding即可。但是不要忘记使用"!important“,因为你想覆盖Bootstrap定义的样式。下面是一个例子:

代码语言:javascript
复制
<template>
  <div>
    <div class="card d-inline-flex" style="width: 40rem; height:7rem; ">
      <div class="row background">
        <div class="col a">
         <div class="p-5 bg-info rounded-left ">Flex item 1</div>
        </div>
        <div class="col a">
          <div class="p-5 bg-info rounded-0 ">Flex item 1</div>
        </div>
        <div class="col a">
          <div class="p-5 bg-info rounded-right">Flex item 1</div>
        </div>
      </div>
    </div>
  </div>
</template>    
<script></script>    
<style>
.background {
  background-color: #dcdcdc;
}
.d {
  margin-left: 4px;
}
.a {
padding-left:0 !important!;
padding-right:0 !important!;
}
</style>

在这里,我使用了一个名为a的自定义类,只需使用padding来获得所需的空间。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64740557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档