靴子对齐按钮在左边

时间:2017-10-14 06:56:49

标签: css alignment bootstrap-modal bootstrap-4

我如何对齐左边的按钮?我正在使用bootswatch / Litera它是bootstrap 4 beta主题。

我已经尝试在按钮上添加float-left类并将其放在div中,但结果是一样的。

enter image description here

我在模态页脚上添加了它。

<div class="modal-footer">
    <div class="float-left">
        <button type="button" class="btn btn-outline-primary btn-circle float-left">
            <i class="fa fa-plus"></i>
        </button>
    </div>
    <button type="button" class="btn btn-primary">Save</button>
</div>

4 个答案:

答案 0 :(得分:2)

试试这个。只为按钮对齐leftside添加此css。然后单击demo模式按钮以检查弹出窗口。

#myModal .modal-footer {  
 justify-content: space-between;  
}

#myModal .modal-footer {  
  justify-content: space-between;  
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
   demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">      
          <button type="button" class="btn btn-outline-primary btn-circle">
              <i class="fa fa-plus"></i>
          </button>
          <button type="button" class="btn btn-primary">Save</button>
     </div>
    </div>
  </div>
</div>

答案 1 :(得分:1)

<div class="modal-footer">
<div class="pull-left">
    <button type="button" class="btn btn-outline-primary btn-circle pull-left">
        <i class="fa fa-plus"></i>
    </button>
</div>
<button type="button" class="btn btn-primary">Save</button>

你可以添加&#34;左拉&#34;而不是&#34; float-left&#34;

答案 2 :(得分:1)

试试这个:

.modal-footer > .float-left {
    width: 100%;
}

&#13;
&#13;
.modal-footer>.float-left {
    width: 100%;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="modal-footer">
    <div class="float-left">
        <button type="button" class="btn btn-outline-primary btn-circle float-left">
            <i class="fa fa-plus"></i>
        </button>
    </div>
    <button type="button" class="btn btn-primary">Save</button>
</div>
&#13;
&#13;
&#13;

答案 3 :(得分:0)

你用你的风格编写简单的CSS

.modal-footer { 
        display: block;
        -webkit-box-pack: inherit;
        -webkit-justify-content: inherit;
        -ms-flex-pack: inherit;
        justify-content: inherit;
    }
    .btn-save  {
        align-self: right;
    }

流动这个HTML代码:

 <div class="modal-footer">
    <div class="plus-button">
         <button type="button" class="btn btn-outline-primary btn-circle float-left">
            <i class="fa fa-plus"></i>
         </button>
    </div>
    <button type="button" class="btn btn-primary float-right">Save</button>
 </div>