CSS 引导按钮上没有边距底部?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26427963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No margin-bottom on bootstrap button?
提问by Sébastien Gicquel
I'm using button element in a bootstrap template.
我在引导模板中使用按钮元素。
I was wondering if it is the normal behavior in bootstrap :
我想知道这是否是 bootstrap 的正常行为:
When there is not enough space to show all the buttons on one line, or when the window is resized, some buttons are shown on a 2nd line and it's ok like that but there is no margin-bottom.
当没有足够的空间在一行上显示所有按钮时,或者调整窗口大小时,一些按钮会显示在第二行,这样也可以,但没有底部边距。
I can add it :
我可以添加它:
.btn {
margin-bottom: 5px;
}
But i find it strange that it is not handled by bootstrap.
但我觉得奇怪的是它不是由引导程序处理的。
Maybe i'm doing something wrong ?
也许我做错了什么?
SOURCE: http://jsfiddle.net/Vinyl/zx9oefya/
来源:http: //jsfiddle.net/Vinyl/zx9oefya/
<button type="button" class="btn btn-primary btn_plus_infos" data-toggle="collapse" data-target="#plus_infos">Plus d'infos</button>
<button type="button" class="btn btn-primary btn_plus_infos" data-toggle="collapse" data-target="#plus_infos">Plus d'infos</button>
<button type="button" class="btn btn-primary btn_plus_infos" data-toggle="collapse" data-target="#plus_infos">Plus d'infos</button>
采纳答案by ckuijjer
In Bootstrap's buttons.less
and button-groups.less
there's nothing about margin-top or margin-bottom. Having a margin by default would likely conflict when combining it with other elements (e.g. a form)
在 Bootstrap 中buttons.less
,button-groups.less
没有关于 margin-top 或 margin-bottom 的内容。默认情况下,将边距与其他元素(例如表单)组合时可能会发生冲突
I think the best solution might be adding all buttons inside a btn-toolbar
and to style that combination:
我认为最好的解决方案可能是在 a btn-toolbar
and 中添加所有按钮来设置该组合的样式:
.btn-toolbar .btn {
margin-bottom: 5px;
}
回答by Berthy
I think that it's the normal behavior ( not 100% sure ) because it's "cleaner" to add margin ourselves when we want it that having to remove the default margin when we don't want it, from my opinion...
我认为这是正常行为(不是 100% 确定),因为在我们想要的时候自己添加边距比在我们不想要的时候删除默认边距更“干净”,在我看来......
http://getbootstrap.com/components/#btn-groups
http://getbootstrap.com/components/#btn-groups
There's no margin
on bootstrap's buttons examples, only on the parent div
class btn-group
but it's coming from a different stylesheet ( docs.min.css ). So I think it's that way for devs to add their own custom margin
s.
margin
bootstrap 的按钮示例没有,只有在父div
类上,btn-group
但它来自不同的样式表( docs.min.css )。所以我认为开发人员可以通过这种方式添加自己的 custom margin
s。
See here:
看这里:
回答by Berthy
Just add the spacing class. m
for margin and p
for padding.
只需添加间距类。m
用于边距和p
填充。
<button class="btn btn-success mr-2" type="submit">Add</button>
<button class="btn btn-danger mr-2" type="button">Delete</button>
so, here mr
is margin-right. similarly, you can add do for other cases.
所以,这里mr
是边距。同样,您可以为其他情况添加 do。
回答by Zdenoslav
mb-5 = margin bottom ..just add that :) sorted :)
mb-5 = 边距底部 .. 只需添加 :) 排序 :)