You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bootstrap Table中TD内操作按钮换行问题解决请求

解决Bootstrap表格Action列按钮换行问题

针对你遇到的表格Action列按钮换行问题,结合Bootstrap的特性,有几种简单直接的解决方法:

方法1:使用Bootstrap btn-group 组件

将三个按钮包裹在btn-group容器中,Bootstrap会自动让按钮排列在同一行,同时还能提供按钮分组的视觉效果:

<td>
  <div class="btn-group" role="group" aria-label="Action buttons">
    <button type="submit" class="btn btn-sm btn-primary">Submit</button>
    <button type="button" class="btn btn-sm btn-warning">Update</button>
    <button type="button" class="btn btn-sm btn-danger">Remove</button>
  </div>
</td>

方法2:给按钮添加行内块级样式类

利用Bootstrap的工具类d-inline-block(或d-inline)强制按钮保持行内布局,避免换行:

<td>
  <button type="submit" class="btn btn-sm btn-primary d-inline-block">Submit</button>
  <button type="button" class="btn btn-sm btn-warning d-inline-block">Update</button>
  <button type="button" class="btn btn-sm btn-danger d-inline-block">Remove</button>
</td>

方法3:调整Action列的最小宽度

如果是因为列宽不足导致按钮换行,可以给Action列设置最小宽度,确保有足够空间容纳按钮:

<!-- 表头列设置 -->
<th style="min-width: 220px;">Action</th>
<!-- 表格内容列设置 -->
<td style="min-width: 220px;">
  <!-- 你的按钮代码 -->
</td>

额外注意

  • 检查是否有自定义CSS给按钮设置了display: block,如果有需要覆盖该样式
  • 优先使用Bootstrap原生类,减少自定义CSS的编写,保持项目样式统一

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 14:08:12