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

如何在Tabulator中垂直对齐列标题?是否有类headerHozAlign的属性?

Tabulator表头垂直对齐实现方案

Tabulator没有提供和headerHozAlign对应的内置垂直对齐属性,需要通过CSS来实现表头标题的垂直对齐,结合你已有的样式,修改方案如下:

修改现有CSS样式

在你已定义的表头样式中添加垂直对齐相关属性:

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
    white-space: normal !important;
}

.tabulator-col-title {
    height: 2rem;
    /* 垂直居中对齐,可根据需求替换为flex-start(顶部)或flex-end(底部) */
    display: flex;
    align-items: center;
    /* 配合水平居中,与headerHozAlign:center效果一致,可保留 */
    justify-content: center;
}

原理说明

通过将.tabulator-col-title设置为flex容器,利用align-items属性控制文本在垂直方向的对齐:

  • align-items: center:实现垂直居中(匹配你期望的效果)
  • align-items: flex-start:表头文本顶部对齐
  • align-items: flex-end:表头文本底部对齐

该方案与你已设置的headerHozAlign: "center"、文本换行样式完全兼容,可直接达到目标效果。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 05:00:00