简体   繁体   English

一次选择多个子元素

[英]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 通过使用Chrome检查工具复制选择器,我已将所需的参数隔离到此

#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. 上面的XX是数字。 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 由于编号会更改用户是否具有头像,因此我必须用大约200条单独的行来填充样式,如下所示

#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? 有没有一种方法可以用单个选择器选择所有这些方法?或者是CSS的局限性导致我无法对第一个tr:nth-​​child(2)条目进行通配?

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" 编辑:我找不到接受答案按钮,这是答案:“您能删除> tr:nth-​​child(3)>的nth-child自变量,使其变为> tr>吗?– S. Walker ”

it makes more sense to add a class or id to the element for which you want to alter the styles. 在要更改样式的元素上添加类或id更为有意义。 anyway upload your html for better understanding of the problem 无论如何,请上传您的html以更好地理解问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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