bootstrap中怎么设置按钮位置

尚
原创
2019-07-27 11:48:55 7856浏览

bootstrap中可以使用pull-right, pull-left、text-right, text-center, text-left来设置按钮的位置。

例:

以下是一段简单的示例,需要将其中每个li中的按钮靠右对齐:

<ul>
    <li>One <input class="btn pull-right" value="test"></li>
    <li>Two <input class="btn pull-right" value="test2"></li>
 </ul>

方法一:

在Bootstrap 3中,可以使用pull-right样式类来将元素右对齐,如下:

<!--https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css-->
<ul>
  <li>One <button class="btn btn-primary pull-right">test</button></li>
  <li>Two <button class="btn btn-danger  pull-right">test2</button></li>
 </ul>

适当调整一下每个li的高度,如下:

li{line-height:40px; height:40px;}

方法二:

在Bootstrap 3中,还可以使用text-right样式类来右对齐按钮,如下:

<div class="row">
    <div class="col-xs-12">
        <div class="text-right">
            <button type="button" class="btn btn-default">Default</button>
        </div>
    </div>
   </div>

方法三:

在Bootstrap 4中,pull-right样式类已经更名为float-right类名了,如下:

<div class="row">
    <div class="col-12">One <input type="button" class="btn float-right" value="test"></div>
    <div class="col-12">Two <input type="button" class="btn float-right" value="test"></div>
</div>

推荐:bootstrap入门教程

以上就是bootstrap中怎么设置按钮位置的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。