表格标题颜色

huangapple go评论56阅读模式
英文:

Tabulator header color

问题

Tabulator不接受标题颜色更改

通过以下CSS,我试图更改所有列的标题颜色,但我没有得到这个调整

尝试这样做,但没有效果。
我使用vue3 + vite + Tabulator 5.4

<style scoped>
   .tabulator {
     font-size: 12px;
     width: 100%;
   }
   .tabulator .tabulator-header,
   .tabulator-col .headerBackgroundColor {
     background-color: #acacac;
   }
</style>

这是我的Tabulator

tabulator.value = new Tabulator('#tabulator', {
     data: dataRelatorio.value,
     layout: 'fitColumns',
     autoResize: true,
     pagination: 'local',
     paginationSize: 20,
     rowHeight: 25,
     paginationSizeSelector: [10, 20, 30, 50, 100, 200, 500, 1000],
     movableColumns: true,
     paginationCounter: 'rows',
     responsiveLayout: 'hide',
     placeholder: '未找到记录',
     locale: 'pt-BR',
     langs: {
       'pt-BR': {
         pagination: {
           page_title: '显示页面',
           first: '第一页',
           first_title: '第一页',
           last: '下一页',
           last_title: '下一页',
           prev: '上一页',
           prev_title: '上一页',
           next: '下一页',
           next_title: '下一页',
           all: '全部',
         },
       },
     },
     columns: columns,
     rowFormatter: function (row) {
       //console.log(row.getData());
       if (row.getData().in_delayed === 'delayed') {
         const children = row.getElement().childNodes;
         children.forEach((child) => {
           child.style.backgroundColor = '#FFFACD';
         });
       }
     },
   });

请注意,代码部分未进行翻译。

英文:

Tabulator does not accept header color change

Through the css below, I'm trying to change the header color of all my columns, but I'm not getting this adjustment

tried to do it this way but it's not going.
I use vue3 + vite + tabulator 5.4

&lt;style scoped&gt;
   .tabulator {
     font-size: 12px;
     width: 100%;
   }
   .tabulator .tabulator-header,
   .tabulator-col .headerBackgroundColor {
     background-color: #acacac;
   }
&lt;/style&gt;

this is my tabulator

tabulator.value = new Tabulator(&#39;#tabulator&#39;, {
     data: dataRelatorio.value,
     layout: &#39;fitColumns&#39;,
     autoResize: true,
     pagination: &#39;local&#39;,
     paginationSize: 20,
     rowHeight: 25,
     paginationSizeSelector: [10, 20, 30, 50, 100, 200, 500, 1000],
     movableColumns: true,
     paginationCounter: &#39;rows&#39;,
     responsiveLayout: &#39;hide&#39;,
     placeholder: &#39;No record found&#39;,
     locale: &#39;pt-BR&#39;,
     langs: {
       &#39;pt-BR&#39;: {
         pagination: {
           page_title: &#39;Show page&#39;,
           first: &#39;First&#39;,
           first_title: &#39;First page&#39;,
           last: &#39;Next&#39;,
           last_title: &#39;Next page&#39;,
           prev: &#39;Previous&#39;,
           prev_title: &#39;Previous page&#39;,
           next: &#39;Next&#39;,
           next_title: &#39;Next Page&#39;,
           all: &#39;All&#39;,
         },
       },
     },
     columns: columns,
     rowFormatter: function (row) {
       //console.log(row.getData());
       if (row.getData().in_delayed === &#39;delayed&#39;) {
         const children = row.getElement().childNodes;
         children.forEach((child) =&gt; {
           child.style.backgroundColor = &#39;#FFFACD&#39;;
         });
       }
     },
   });

答案1

得分: 0

这应该可以工作:

<style>
.tabulator .tabulator-header .tabulator-col {
  background-color: #acacac;
}
</style>

注意:

  • 我没有在<style>标签上使用scoped指令。
  • 你可以在组件中拥有多个<style>标签,一些使用scoped,一些不使用。不使用scoped的那些是普通的CSS,它们适用于整个DOM。
  • 你也可以将上述样式应用在scoped样式标签内。选择器很可能是.tabulator :deep(.tabulator-header .tabulator-col),但在你提供一个可运行的最小示例之前,我无法确定。这样我可以检查它。
英文:

This should work:

&lt;style&gt;
.tabulator .tabulator-header .tabulator-col {
  background-color: #acacac;
}
&lt;/style&gt;

Notes:

  • I didn't use the scoped directive on &lt;style&gt; tag.
  • you can have more than one &lt;style&gt; tag in a component, some scoped and some regular. The regular ones are "normal" CSS, they apply to the entire DOM.
  • you can also apply the above styles inside a scoped style tag. The selector would most likely be .tabulator :deep(.tabulator-header .tabulator-col), but I can't know for sure until you provide a runnable minimal example, so I could inspect it.

huangapple
  • 本文由 发表于 2023年2月19日 00:16:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75494654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定