【问题标题】:How to change header background color and font color in Handsontable如何在 Handsontable 中更改标题背景颜色和字体颜色
【发布时间】:2015-03-25 06:21:05
【问题描述】:

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

【问题讨论】:

    标签: handsontable


    【解决方案1】:

    您可以为此使用 jquery 或 css。比如给所有的span.colHeader应用一个背景色:

    .handsontable span.colHeader {
        text-color: #B2B2FF; /* pink ish */
        background-color: #FF7878; /* red */
    }
    

    或者更简单,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>']
      }
    )
    

    【讨论】:

      【解决方案2】:

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

         .handsontable table thead th{
              background-color: green;
              color:white;
              font-weight:bold;
              font-size:12px;
          }
      

      【讨论】:

      • 将每个 HOT 放在自己的 div 中,并带有一个类。然后使用适当的选择器。 &lt;div class="divHot1"&gt;&lt;div id="divHOTTable"&gt;... 在你的 CSS 中,选择使用 div.divHot1 .handsontable table thead th
      【解决方案3】:

      测试这个css来改变handsontable标题颜色

      .handsontable th {color: #f5ffa5 !important; background: #78DEFF !important; }

      【讨论】:

      • 请解释您的解决方案。不要只是发布代码。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      相关资源
      最近更新 更多