hellzone
hellzone

Reputation: 5236

How to change cell color of datatables?

I am using Datatables and I want to update my table colors.(all cell colors including headers).

I found some solutions but problem is I have nearly 200 tables and I don't want to update my tables colors one by one. Is there any way to change color of all tables?

EDIT: I am using simple Datatables like;

$(document).ready(function() {
   $('#myDt').DataTable( {
       "paging":   false,
       "ordering": false,
       "info":     false
   } );
} );

Upvotes: 1

Views: 1340

Answers (1)

DreamTeK
DreamTeK

Reputation: 34177

This is how I do it.

Apply a class (DT in this case) to each Datatable.

Then use css to overwrite the colours.

HTML

<table id="myDT" class="DT">
//Code here ...
</table>

CSS

For the header:

.DT thead th,
.DT tfoot td {
  background-color:#111;
}

For rows and alternate rows:

.DT tbody tr.even,
.DT tbody tr.odd{
  background-color: #eaeaea;
}

Upvotes: 1

Related Questions