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


当前回答

我的技巧。不是很干净,但对我来说还行

<p>&nbsp;</p>

其他回答

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>

好吧,只是让你知道发生了什么,我固定使用一些新的类Acyra上面说:

.top5 { margin-top:5px; }
.top7 { margin-top:7px; }
.top10 { margin-top:10px; }
.top15 { margin-top:15px; }
.top17 { margin-top:17px; }
.top30 { margin-top:30px; }

只要我想,我做<div class="row top7"></div>

为了更好的响应,你可以添加margin-top:7%而不是5px,例如:D

您可以添加以下代码:

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

在Twitter引导中编辑或重写行是一个坏主意,因为这是页面脚手架的核心部分,您将需要没有顶部边距的行。

要解决这个问题,可以创建一个新类“top-buffer”,添加所需的标准裕度。

.top-buffer { margin-top:20px; }

然后在需要上边距的行div上使用它。

<div class="row top-buffer"> ...

有一个技巧可以自动为容器中的第2 +行添加边距。

.container-row-margin .row + .row {
    margin-top: 1rem;
}

将.container-row-margin添加到容器中,结果如下:

完整的HTML:

<div class="bg-secondary text-white">
    div outside of the container.
</div>
<div class="container container-row-margin">
    <div class="row">
        <div class="col col-4 bg-warning">
            Row without top margin
        </div>
    </div>
    <div class="row">
        <div class="col col-4 bg-primary text-white">
            Row with top margin
        </div>
    </div>
    <div class="row">
        <div class="col col-4 bg-primary text-white">
            Row with top margin
        </div>
    </div>
</div>
<div class="bg-secondary text-white">
    div outside of the container.
</div>

取自官方样品。