How to implement css to style a subclass if there is a subclass

problem description

I want to dynamically add a style to the parent class, but whether I want to add this style depends on whether it contains a subclass. I"m not sure if I want to style the parent class, because all the parent classes have the same class name tag, and only the subclasses have a distinction

related codes

<tr>
    <td></td>
</tr>

<tr>
    <td class="child"></td>
</tr>

what result do you expect? What is the error message actually seen?

if there is a subclass child, let the tr be hidden, and if there is no tr, then do not do the processing, how to achieve?

Jun.18,2021

normally this cannot be done. But there are some speculative methods that can achieve certain results. Take a look at teacher Zhang Xinxu's an article


you can uniformly load the style into the parent.
for example, by adding class to the parent. To style the children.

 .checkbox{

}
.checked .checkbox{

}

as shown above, you can dynamically add a parent class class, and below this class class is the 'some subclass' you want

<div class="normal  active"></div>

//css
<style lang='scss' scope>
.normal{...}//
.active {
    .childClass {...} //
}
</style>
In

css, there seems to be no way to select the class class of the child element. You can judge it with js. Of course, the style problem can be solved by using css as much as possible, so there can be some clever solutions.

Welcome to my Wechat official account: Front end Guide I hope my answer will be useful to you
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3783b-4d73a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3783b-4d73a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?