use*_*055 2 html css twitter-bootstrap
我目前正在使用BootStrap 3.我无法使按钮组成为中心.
HTML
<div class="container" style="margin-top:100px;">
<div class="btn-group" style="margin:0 auto">
<button type="button" class="btn btn-default" >Left</button>
<button type="button" class="btn btn-default" >Middle</button>
<button type="button" class="btn btn-default" >Right</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
Jon*_*hez 13
Bootstrap 4 使用
text-center或mx-auto或container-fluid您可以使用此 hack text-center(这不仅适用于文本)
或者使用确切的 boostrap4 类 mx-auto
例如
class="text-center"或 class="mx-auto"
在上下文中
<div class="btn-group text-center"> or <div class="btn-group mx-auto">
Run Code Online (Sandbox Code Playgroud)
尽量不要使用内联样式(不好的做法)
<div class="btn-group" style="margin:0 auto">
Run Code Online (Sandbox Code Playgroud)
参考这里:
text-center=>
https://getbootstrap.com/docs/4.0/utilities/text/
mx-auto=> https://getbootstrap.com/docs/4.0/utilities/spacing/#horizontal-centering
编辑:Guillemo Mansilla 的答案更好。相同的技术,但更好地利用现有的 Bootstrap 类。
您可以text-align: center在.container. 不需要margin: 0 auto.
.container {
text-align: center;
margin-top: 100px;
}
Run Code Online (Sandbox Code Playgroud)
http://jsbin.com/oyaDokOw/2/edit
| 归档时间: |
|
| 查看次数: |
15875 次 |
| 最近记录: |