So I have this table:
<table>
<thead>
<tr>
<th style="width: 40%; text-align: center; vertical-align: center;">Nr.<br> crt.</th>
<th style="font-weight: bold; width: 210%; height: 25; text-align: center; vertical-align: center;">Asistent</th>
<th style="font-weight: bold; width: 210%; height: 25; text-align: center; vertical-align: center;">Ambulantier</th>
<th style="text-align: center; vertical-align: center;">Ambulanta</th>
@foreach($dates as $date)
@if($date['day_name'] == 'S' || $date['day_name'] == 'D')
<th style="width: 40%; text-align: center; vertical-align: center; font-weight: bold; color: red;">{{$date['day']}}<br> {{$date['day_name']}}</th>
@else
<th style="width: 40%; text-align: center; vertical-align: center; font-weight: bold;">{{$date['day']}}<br> {{$date['day_name']}}</th>
@endif
@endforeach
</tr>
</thead>
<tbody>
@foreach($interventions as $intervention)
<tr>
<td>0</td>
<td>{{$intervention->employee_one->name}}</td>
<td>{{$intervention->employee_two->name}}</td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
And this is what is generating:
As you can see, some numbers in the header have the red color. How can I color the WHOLE column with red if the respective <th>
is also red?
I was thinking to use js, and it would look something like this (just an idea, not the actual code lol):
if(header(current_td).hasProperty('color: red')) {
apply(color.red);
}
How can I do this?
4
Answers
You can make use of
colgroup
as such:Rather than formatting each individual cell,
colgroup
allows you to apply formatting to a all the cells in a columns instead.In javascript:
Using only JS with inline style, you can do something like this: