0

I have a CSS class .custom-service-table, with the following style:

.custom-service-table{
   background: transparent;
}

This CSS actually set the background of a table to transparent. For each row of the table, depending on a value, I need to update the table background.

For example, I have a bool isActive, if isActive is true then I need to update the table background to white.

Once I am doing the check, I am adding a CSS class to the row, active-row.

How can I apply a style to the class, active-row, so as to set the table background to white in CSS?

inizio
  • 2,108
  • 13
  • 18
refresh
  • 1,203
  • 1
  • 17
  • 50
  • A `class` on the `tr` element has no way to affect styling of any parent elements. ***Any*** selector will always only affect the targeted element, and by means of CSS inheritance, child elements. – connexo Nov 20 '19 at 08:14
  • During your loop for the TR, if bool is true, add class, if not, don't add class. We could help you better if you include your html and the loop. – Jerdine Sabio Nov 20 '19 at 08:14
  • how and where do you add `isActive` and `active-row` to the code? – Ramon de Vries Nov 20 '19 at 08:19
  • @RamondeVries: If the bool isActive is true then add the class active-row. – refresh Nov 20 '19 at 08:22
  • @JerdineSabio: This is already done. What I want is that when the class active-row is present then the css should be such that the background is white. – refresh Nov 20 '19 at 08:23
  • @connexo : so there is no way of doing what I want..? – refresh Nov 20 '19 at 08:24
  • well you cannot check for an child element having a class and then style the parent if its either true or false, or you should use javascript – Ramon de Vries Nov 20 '19 at 08:24
  • @refresh I see. You could set that via javascript on page ready. Are the contents added dynamically (after page load, via script)? – Jerdine Sabio Nov 20 '19 at 08:46
  • @JerdineSabio : On page load, But it is a dynamic grid – refresh Nov 20 '19 at 09:28

0 Answers0