如何添加边缘顶部类="行"元素使用twitter引导框架?


当前回答

您可以添加以下代码:

[class*="col-"] {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

其他回答

just take a new class beside every row and apply css of margin-top: 20px;
here is the code below
<style>
  .small-top
   {
     margin-top: 25px;  
   }
</style>    
<div class="row small-top">
   <div class="col-md-12">
   </div>
 </div>

我正在使用这些类来修改上边距:

.margin-top-05 { margin-top: 0.5em; }
.margin-top-10 { margin-top: 1.0em; }
.margin-top-15 { margin-top: 1.5em; }
.margin-top-20 { margin-top: 2.0em; }
.margin-top-25 { margin-top: 2.5em; }
.margin-top-30 { margin-top: 3.0em; }

当我需要一个元素与上面的元素有2em的间距时,我这样使用它:

<div class="row margin-top-20">Something here</div>

如果你喜欢像素,所以改变em到px有你的方式。

您可以添加以下代码:

[class*="col-"] {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

你可以使用下面的类进行引导4:

mt-0 mt-1 mt-2 mt-3 mt-4 ...

裁判:https://v4-alpha.getbootstrap.com/utilities/spacing/

Bootstrap3

CSS(只有排水沟,周围没有边距):

.row.row-gutter {
  margin-bottom: -15px;
  overflow: hidden;
}
.row.row-gutter > *[class^="col"] {
  margin-bottom: 15px;
}

CSS(等距,15px/2):

.row.row-margins {
  padding-top: 7px; /* or margin-top: 7px; */
  padding-bottom: 7px; /* or margin-bottom: 7px; */
}
.row.row-margins > *[class^="col"] {
  margin-top: 8px;
  margin-bottom: 8px;
}

用法:

<div class="row row-gutter">
    <div class="col col-sm-9">first</div>
    <div class="col col-sm-3">second</div>
    <div class="col col-sm-12">third</div>
</div>

(对于SASS或LESS, 15px可以是bootstrap的变量)