Если ваша таблица всегда имеет одинаковую структуру HTML, вы можете выбрать через: nth-child () любой элемент внутри HTML дерева.
например: #checkbox_id:checked + table tbody tr:nth-child(1) td:nth-child(2)
label {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
display: inline-block;
cursor: pointer;
margin:5px;
}
#checkbox_id:checked + table {
background-color: yellow;
}
#checkbox_id:checked + table tbody tr:nth-child(1) td:nth-child(2) {
background-color: red;
}
/*Table styles*/
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal; width: 50px; height: 50px;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal; width: 50px; height: 50px;}
.tg .tg-0lax{text-align:left;vertical-align:top}
<!DOCTYPE html>
<html lang="it" dir="ltr">
<head>
<meta charset="utf-8">
<title>Check6</title>
</head>
<body>
<label for="checkbox_id">CLICCA</label>
<input type="checkbox" id="checkbox_id">
<table class="tg">
<thead>
<tr>
<th class="tg-0lax"></th>
<th class="tg-0lax"></th>
<th class="tg-0lax"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-0lax"></td>
<td id="red"></td>
<td class="tg-0lax"></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
</tbody>
</table>
</body>
</html>
https://developer.mozilla.org/en-US/docs/Web/CSS/: nth-child
Псевдокласс :nth-child()
CSS сопоставляет элементы в зависимости от их положения в группе братьев и сестер.
другой вариант, выберите ячейки с классом и перезапишите цвет bg
#checkbox_id:checked + table td {
background-color: red;
}
#checkbox_id:checked + table [class]{
background-color: yellow;
}
label {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
display: inline-block;
cursor: pointer;
margin:5px;
}
#checkbox_id:checked + table td {
background-color: red;
}
#checkbox_id:checked + table [class]{
background-color: yellow;
}
/*Table styles*/
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal; width: 50px; height: 50px;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal; width: 50px; height: 50px;}
.tg .tg-0lax{text-align:left;vertical-align:top}
<!DOCTYPE html>
<html lang="it" dir="ltr">
<head>
<meta charset="utf-8">
<title>Check6</title>
</head>
<body>
<label for="checkbox_id">CLICCA</label>
<input type="checkbox" id="checkbox_id">
<table class="tg">
<thead>
<tr>
<th class="tg-0lax"></th>
<th class="tg-0lax"></th>
<th class="tg-0lax"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-0lax"></td>
<td id="red"></td>
<td class="tg-0lax"></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
</tbody>
</table>
</body>
</html>