[英]I need to select the first non-hidden/visible child element excluding records with a specific class only using css
In the below example, I want to change the text color of the first child that is visible.在下面的示例中,我想更改可见的第一个孩子的文本颜色。
Here <div>
with the class of HideWidget
should be excluded;此处
<div>
应排除 HideWidget 的HideWidget
; so, I want to see "two," "four" and "eight" to be colored red.所以,我想看到“二”、“四”和“八”被涂成红色。
I have tried below css and its showing only "four":我在 css 下尝试过,它只显示“四个”:
.parent.child.field:not(.HideWidget):first-child { color: red; }
<div class='parent'> <div class='child'> <div class='field HideWidget'>One</div> <div class='field'>Two</div> <div class='field'>Three</div> </div> <div class='child'> <div class='field'>Four</div> <div class='field'>Five</div> <div class='field'>Six</div> </div> <div class='child'> <div class='field HideWidget'>Seven</div> <div class='field'>Eight</div> <div class='field'>Nine</div> </div>
` `
.parent.child.field:not(.HideWidget):first-child, .parent.child.field.HideWidget+.field { color: red; }
<div class='parent'> <div class='child'> <div class='field HideWidget'>One</div> <div class='field'>Two</div> <div class='field'>Three</div> </div> <div class='child'> <div class='field'>Four</div> <div class='field'>Five</div> <div class='field'>Six</div> </div> <div class='child'> <div class='field HideWidget'>Seven</div> <div class='field'>Eight</div> <div class='field'>Nine</div> </div>
Should help you with red color on Two, Four and Eight应该可以帮助您在二、四和八上涂上红色
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.