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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:41:17  来源:igfitidea点击:

No margin-bottom on bootstrap button?

csstwitter-bootstrap

提问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/

enter image description here

在此处输入图片说明

<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.lessand button-groups.lessthere'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.lessbutton-groups.less没有关于 margin-top 或 margin-bottom 的内容。默认情况下,将边距与其他元素(例如表单)组合时可能会发生冲突

I think the best solution might be adding all buttons inside a btn-toolbarand to style that combination:

我认为最好的解决方案可能是在 a btn-toolbarand 中添加所有按钮来设置该组合的样式:

.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 marginon bootstrap's buttons examples, only on the parent divclass btn-groupbut it's coming from a different stylesheet ( docs.min.css ). So I think it's that way for devs to add their own custom margins.

marginbootstrap 的按钮示例没有,只有在父div类上,btn-group但它来自不同的样式表( docs.min.css )。所以我认为开发人员可以通过这种方式添加自己的 custom margins。

See here:

看这里:

enter image description here

在此处输入图片说明

回答by Berthy

Just add the spacing class. mfor margin and pfor 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 mris margin-right. similarly, you can add do for other cases.

所以,这里mr是边距。同样,您可以为其他情况添加 do。

回答by Zdenoslav

mb-5 = margin bottom ..just add that :) sorted :)

mb-5 = 边距底部 .. 只需添加 :) 排序 :)