You need to enable JavaScript to run this app. 如何将BootstrapVue表单的搜索按钮对齐到Branch标签下方
优惠活动
大模型
产品
解决方案
定价
更多

如何将BootstrapVue表单的搜索按钮对齐到Branch标签下方

实现方法

当前 Branch 相关元素放在 inline 行内表单里,所有子元素默认沿水平方向排列,所以 Search 按钮会和 Branch 标签、输入框挤在同一行。
直接做如下调整即可实现按钮在 Branch 标签下方的效果:

  • 给包裹 Search 按钮的 <div> 加上 w-100 类,强制让这个容器占满整行宽度,按钮就会自动换行到下一行;因为外层容器已经设置了 text-right,按钮会自动保持右对齐。
  • 如果需要调整按钮和上方输入框的垂直间距,可以给这个容器再加 mt-2/mt-3 这类 Bootstrap 内置间距类,按需调整即可。

修改后的核心代码片段:

<div class="branch">
  <div class="col-8 text-right">
    <b-form inline label-align-sm="right">
      <label for="branch">⠀⠀⠀⠀⠀⠀⠀⠀Branch:</label>
      <div class="col-sm-2">
        <b-form-input v-model="text"></b-form-input>
      </div>
      <!-- 新增 w-100 类实现换行,mt-2 调整上下间距 -->
      <div class="w-100 mt-2">
        <b-button variant="outline-primary">Search</b-button>
      </div>
    </b-form>
  </div>
</div>

如果需要按钮和 Branch 标签左对齐,只要去掉外层 col-8 的 text-right 类,或者给按钮单独添加 text-left 类即可。

内容的提问来源于stack exchange,提问作者Acrylith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.24 12:24:05