Home >Web Front-end >Bootstrap Tutorial >How to set button position in bootstrap

How to set button position in bootstrap

尚
Original
2019-07-27 11:48:558978browse

How to set button position in bootstrap

In bootstrap, you can use pull-right, pull-left, text-right, text-center, text-left to set the position of the button.

Example:

The following is a simple example in which the buttons in each li need to be aligned to the right:

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

Method 1:

In Bootstrap 3, you can use the pull-right style class to right-align elements, as follows:

<!--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>

Adjust the height of each li appropriately, as follows:

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

Method 2:

In Bootstrap 3, you can also use the text-right style class to right-align the button, as follows:

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

Method 3:

In Bootstrap 4, the pull-right style class has been renamed to float-right class name, as follows:

<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>

Recommended: bootstrap introductory tutorial

The above is the detailed content of How to set button position in bootstrap. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn