Say you have:
----------
A
----------
B -> C
----------
Given C is children of B, i want to select all Cs which have a parent B that is sibling of A
Try this:
A ~ B > C
returns all 'C's that are a child of 'B' that is a sibling of 'A'
@Sven also mentioned the '+' adjacent sibling selector which will also work if A and B are 'adjacent' siblings (meaning right next to each other and not divided by other sibling elements.)
.a +.b .c
Here is a jsfiddle where you can test. Notice how the .c
divs that don't match the rule don't get the green background. I wouldn't count on IE to support this though.
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.