简体   繁体   English

如何在引导程序中一个在另一个之上的列之间留出空间

[英]how to give space between columns which is one above the other in bootstrap

i have a website done in bootstrap, in which I am listing some data using PHP, so I have 18 categories, 18 categories are listed in columns in a single row, whose code is like below:我有一个用bootstrap做的网站,我用PHP列出了一些数据,所以我有18个类别,18个类别列在一行的列中,其代码如下:

 <div class="row"> <?php foreach($categories as $val){?> <div class="col-xl-2 col-sm-6"> <div class="card bg-card-light bg-primary-card bg-white"> <div class="card-body"> <div class="cat-item text-center"> <a href="<?= base_url();?>categories?category=<?= $val->category_name?>"></a> <div class="cat-icon bg-primary-transparent brround text-primary"> <!-- <i class="fa fa-hospital-o"></i> --> <img src="<?= base_url()?>uploads/categoryicon/<?= $val->category_icon?>"> </div> <div class="cat-desc"> <h5 class="mb-2"> <?= $val->category_name?> </h5> </div> </div> </div> </div> </div> <?php }?> </div>

在此处输入图片说明

as you can see in this pic, the 1st column group and second column group are very close to each other, can anyone tell me how to give spacing between them.正如你在这张图片中看到的,第一列组和第二列组彼此非常接近,谁能告诉我如何给它们之间的间距。 thanks in advance提前致谢

You can add padding to the bottom element.您可以向底部元素添加填充。

I've added a snippet using your code and used an example image and text.我已经使用您的代码添加了一个片段,并使用了示例图像和文本。

This is the only css added:这是唯一添加的 css:

.mb-2 {
padding-top: 30px;
background-color: black;
color: white;
}

Additionally, if you want to target the entire bottom div you can use margin on the div class like this:此外,如果您想定位整个底部 div,您可以在 div 类上使用margin ,如下所示:

.cat-desc {
margin-top: 30px;
background-color: black;
color: white;
}

 .mb-2 { padding-top: 30px; background-color: black; color: white; }
 <div class="row"> <?php foreach($categories as $val){?> <div class="col-xl-2 col-sm-6"> <div class="card bg-card-light bg-primary-card bg-white"> <div class="card-body"> <div class="cat-item text-center"> <a href="<?= base_url();?>categories?category=<?= $val->category_name?>"></a> <div class="cat-icon bg-primary-transparent brround text-primary"> <!-- <i class="fa fa-hospital-o"></i> --> <img src="https://cdn.pixabay.com/photo/2020/08/25/18/28/workplace-5517744__340.jpg"> </div> <div class="cat-desc"> <h5 class="mb-2"> Bottom </h5> </div> </div> </div> </div> </div> <?php }?> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM