【问题标题】:Align buttons left, center, right左、中、右对齐按钮
【发布时间】:2017-10-16 16:45:18
【问题描述】:

我正在使用 Bootstrap 4 测试版。我希望工作流导航部分中的按钮与左侧的后退按钮对齐,居中的两个取消按钮和右侧的下一步按钮。

这是我的编码方式:

  <button type="button" class="btn btn-secondary float-left">Back</button>
  <div class="text-center">
    <button type="button" class="btn btn-danger">Cancel</button>
    <button type="button" class="btn btn-secondary"">Save and Exit</button>
  </div>
  <button type="submit" class="btn btn-primary float-right">Next</button>

这已正确定位左侧按钮和中间按钮,但右侧按钮位于右侧其他按钮的下方。

我尝试将右侧按钮放在它自己的 div 中并删除浮动左侧。如何让它们全部对齐?

【问题讨论】:

    标签: bootstrap-4


    【解决方案1】:

    使用 flex 代替浮动:

    <div class="d-flex justify-content-between">
      <button type="button" class="btn btn-secondary">Back</button>
      <div>
        <button type="button" class="btn btn-danger">Cancel</button>
        <button type="button" class="btn btn-secondary">Save and Exit</button>
      </div>
      <button type="submit" class="btn btn-primary">Next</button>
    </div>
    

    【讨论】:

    • 截图会更好。
    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 2021-08-25
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 2021-05-10
    相关资源
    最近更新 更多