如何更改 Handsontable 中的标题背景颜色和字体颜色

Vin*_*ier 5 handsontable

问题:我可以更改单元格的背景颜色,但不能更改标题的背景颜色。我可以更改 Handsontable 中标题的背景颜色和字体颜色吗?

小智 5

在文档头部添加样式标签。这将影响页面上的所有热门网格。还在研究如何让不同的网格以不同的样式显示。

   .handsontable table thead th{
        background-color: green;
        color:white;
        font-weight:bold;
        font-size:12px;
    }
Run Code Online (Sandbox Code Playgroud)


Zek*_*oid 4

您可以使用 jquery 或 css 来实现此目的。例如,将背景颜色应用于所有 span.colHeader:

.handsontable span.colHeader {
    text-color: #B2B2FF; /* pink ish */
    background-color: #FF7878; /* red */
}
Run Code Online (Sandbox Code Playgroud)

或者更简单的是,handsontable 允许使用 HTML 作为 col 标头,因此作为一个选项,您可以使用 HTML 提供标头数组:

hot = new Handsontable(container, {
  data: items,
  startRows: 1,
  colHeaders: ['<label id="header1" style="background-color: blue">I'm the first header"</label>', '<label id="header2" style="background-color: red">I'm the second header"</label>']
  }
)
Run Code Online (Sandbox Code Playgroud)