如何添加边缘顶部类="行"元素使用twitter引导框架?
当前回答
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>
其他回答
如果您只想在一个页面上更改,请添加以下样式规则:
#myCustomDivID .row {
margin-top:20px;
}
对于Bootstrap 4,间距应该使用
简写实用程序类
格式如下:
{财产}{双方}-{大小}
其中财产是其中之一:
M -用于设置边距的类 用于设置填充的类
其中边是其中之一:
T -用于设置边距顶部或填充顶部的类 B -用于设置margin-bottom或padding-bottom的类 L -用于设置左边距或左填充的类 R -用于设置右边距或右填充的类 X -用于同时设置*-left和*-right的类 Y -用于同时设置*-top和*-bottom的类 Blank -用于在元素的四个边都设置了边距或填充的类
其中size为其中之一:
0 -用于通过将其设置为0来消除空白或填充的类 1 -(默认情况下)用于将margin或padding设置为$spacer * .25的类 2 -(默认情况下)用于将margin或padding设置为$spacer *的类 3 -(默认情况下)用于将margin或padding设置为$spacer的类 4 -(默认情况下)用于将margin或padding设置为$spacer * 1.5的类 5 -(默认情况下)用于将margin或padding设置为$spacer * 3的类 Auto -用于将边距设置为Auto的类
所以你应该做以下任何一件事:
<div class="row mt-1">
<div class="row mt-2">
...
<div class="row mt-5">
更多的解释请阅读文档。 在这里试试现场的例子。
我的技巧。不是很干净,但对我来说还行
<p> </p>
Bootstrap 4 alpha,用于margin-top: CSS类名的简写mt-1, mt-2 (mt-lg-5, mt-sm-2) 底部也一样,右,左,还有auto类ml-auto
<div class="mt-lg-1" ...>
在变量.scss中,单位从1到5 这意味着如果你设置mt-1它会给出。25雷姆的边距。
$spacers: (
0: (
x: 0,
y: 0
),
1: (
x: ($spacer-x * .25),
y: ($spacer-y * .25)
),
2: (
x: ($spacer-x * .5),
y: ($spacer-y * .5)
),
3: (
x: $spacer-x,
y: $spacer-y
),
4: (
x: ($spacer-x * 1.5),
y: ($spacer-y * 1.5)
),
5: (
x: ($spacer-x * 3),
y: ($spacer-y * 3)
)
) !default;
在这里阅读更多
https://v4-alpha.getbootstrap.com/utilities/spacing/#horizontal-centering
有时候margin-top会导致设计问题:
http://www.w3.org/TR/CSS2/box.html#collapsing-margins
所以,我建议创建“margin-bottom classes”而不是“margin-top classes”,并将它们应用到前一项。
如果你正在使用Bootstrap导入LESS Bootstrap文件,尝试用比例Bootstrap主题空间定义边缘-底部类:
.margin-bottom-xs {margin-bottom: ceil(@line-height-computed / 4);}
.margin-bottom-sm {margin-bottom: ceil(@line-height-computed / 2);}
.margin-bottom-md {margin-bottom: @line-height-computed;}
.margin-bottom-lg {margin-bottom: ceil(@line-height-computed * 2);}