简体   繁体   中英

Selecting multiple sub elements at once

So I am trying to write a Stylish style to remove the black background of avatars on a forum I frequent (they put a black background so transparencies are black instead of white so stand out from the forum, which I dislike).

By copying the selector with the Chrome inspect tool I have isolated the needed argument to this

#mainpostcontent > table > tbody > tr > td > table.forumline > tbody > tr:nth-child(XX) > td:nth-child(1) > span > table > tbody > tr > td {
    background: none !important;
}

Where the XX above is a number. Since the numbering changes whether a user has an avatar or not, I have to saturate the style with about 200 individial lines like so

#mainpostcontent > table > tbody > tr > td > table.forumline > tbody > tr:nth-child(1) > td:nth-child(1) > span > table > tbody > tr > td {
    background: none !important;
}
#mainpostcontent > table > tbody > tr > td > table.forumline > tbody > tr:nth-child(2) > td:nth-child(1) > span > table > tbody > tr > td {
    background: none !important;
}
#mainpostcontent > table > tbody > tr > td > table.forumline > tbody > tr:nth-child(3) > td:nth-child(1) > span > table > tbody > tr > td {
    background: none !important;
}

and so on.

Is there a way I can select all of these with a single selector or is it a limitation of CSS that prevents me wildcarding the first tr:nth-child(2) entry?

Edit: I can't find the accept answer button, this was the answer: "Could you just remove the nth-child argument of > tr:nth-child(3) > so that it becomes > tr >? – S. Walker"

it makes more sense to add a class or id to the element for which you want to alter the styles. anyway upload your html for better understanding of the problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM