bootstrap - 在两个按钮之间添加水平空间,向右浮动

问题描述

我想在表单的右侧有 2 个按钮,但是当我放置它们时,它们之间没有空格

我有这个

  <div class="form-group row">
     <div class="col-lg-12">
       <button id="btn-add" class="btn btn-primary float-right" type="button">
               <i class="fa fa-plus"></iAdd place
       </button>
      <button id="btn-add-file" class="btn btn-primary float-right" type="button">
               <i class="fa fa-plus"></i>Upload CSV
      </button>
     </div>
  </div>

这就是结果

enter image description here

解决方法

由于您使用的是引导程序,您只需将类 ml-1(或 ml-2 等)添加到“添加地点”按钮。类似:

<button id="btn-add" class="btn btn-primary float-right ml-1" type="button">
    <i class="fa fa-plus"></i>Add place
</button>
,

您需要为第一个按钮添加右边距或为第二个按钮添加左边距。这可以在 CSS 中或使用 Bootstrap spacing utility 完成。