[英]CSS extended adjacent selector
Is there a selector similar to the adjacent selector that will select non-adjacent siblings? 是否有一个与相邻选择器相似的选择器,它将选择不相邻的兄弟姐妹?
like: 喜欢:
.one ? .three { color:red; }
<div class="one">1</div> <div class="two">2</div> <div class="three">3</div>
instead of: 代替:
.one + .two + .three { color: red; }
<div class="one">1</div> <div class="two">2</div> <div class="three">3</div>
The selector you are looking for is the ~
selector, which will do the same as the + selector but won't mind what's on the middle. 您要查找的选择器是~
选择器,该选择器与+选择器相同,但不介意中间的内容。
This code should do the trick: 这段代码可以解决这个问题:
.one ~ .three {}
FYI: Recommended reading on this, this was really useful for me a few years ago. 仅供参考:建议阅读,几年前这对我真的很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.