You need to enable JavaScript to run this app. bootstrap-vue模态框页脚列内无法居中选择框与分页组件的问题
优惠活动
大模型
产品
解决方案
定价
更多

bootstrap-vue模态框页脚列内无法居中选择框与分页组件的问题

问题根因

你反复调整对齐类不生效,核心是两个错误:

  • Flex对齐类加错了位置:Bootstrap的justify-content-*这类布局类,必须加在弹性父容器上,才能控制子元素的位置。原代码里加在子元素b-form-select上的justify-content-end完全没有对应样式,自然不会生效。
  • 容器未撑满列宽:b-form默认是内容宽度,即使对齐类加对了,也只会在自身窄条宽度内生效,达不到在整个col-9列内居中的效果。

另外col-9上的text-right是文本对齐类,对表单、分页这类组件没有作用,可以直接删掉。

两种实现方案,按需选择

方案1:下拉框、分页组件占满列宽后均匀居中

适合需要组件之间留均匀间距的场景,直接修改对应类名即可:

  • 删掉col-9上的text-right
  • 删掉b-form-select上错误的justify-content-end
  • 给b-form补充w-100 justify-content-center align-items-center类,其中align-items-center可选,用于统一两个组件的垂直对齐

修改后的核心代码:

<div class="col-9 border border-primary">
    <b-form inline class="d-flex w-100 justify-content-center align-items-center">
        <b-form-select
            v-model="perPage"
            :options="pagerSelectOptions"
        >
        </b-form-select>

        <b-pagination
            v-model="currentPage"
            :total-rows="totalRows"
            :per-page="perPage"
            size="md"
            hide-goto-end-buttons
        ></b-pagination>
    </b-form>
</div>

方案2:下拉框+分页作为整体在列内居中

适合不需要撑满列宽、希望组件整体紧凑居中的场景:

  • 删掉col-9上的text-right
  • 删掉b-form-select上错误的justify-content-end
  • 给col-9补充d-flex justify-content-center类,无需给b-form加额外宽度类

修改后的核心代码:

<div class="col-9 border border-primary d-flex justify-content-center align-items-center">
    <b-form inline class="d-flex">
        <b-form-select
            v-model="perPage"
            :options="pagerSelectOptions"
        >
        </b-form-select>

        <b-pagination
            v-model="currentPage"
            :total-rows="totalRows"
            :per-page="perPage"
            size="md"
            hide-goto-end-buttons
        ></b-pagination>
    </b-form>
</div>

如果需要给下拉框和分页组件之间增加间距,可给b-form-select加mr-2类即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.11 04:36:04