首页 > 解决方案 > How to display a button to center on the same line?

问题描述

I want display a button to the center of the row, having on the same line a text aligned to the left:

<div class="col-xs-1">
    <div class="card-header">
        <h4 class="card-title">set</h4>
    </div>

    <div class="text-center"> 
        <button type="button" class="btn btn-primary center-block add-option" id="add-option">test</button>
    </div> 
</div>  

The problem is that I got this result: https://jsfiddle.net/DTcHh/96757/

标签: htmlcssbootstrap-4

解决方案


Bootstrap has tons of classes to play with.

One of possible solutions:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

<div class="container-fluid card-header btn-group">
  <h4 class="card-title">set</h4>
  <div class="text-center container">
    <button type="button" class="btn btn-primary center-block add-option" id="add-option">test</button>
  </div>
</div>


推荐阅读