Is it possible to select element based on its neighbour's child class ? (maybe :has???)
So i am wondering.
Structure where I would like to select all div's based on its neighbour's child class but is seems that it does not work. Here is an example: https://codepen.io/H4ds0n/pen/WNYVEjX
My goal is to make all div's background red if any of its neighbour's child has class selected
5 Replies
you want all of them to be red from a to d?
yup but the red color should be on div directly
this is a little bit simplified example so it could make no sense but all i want is that if any of its neighbour's child has class "X" then do something with it
try
Perfect, seems that it is working. Thanks for the help
If you want to select only the siblings and not the element that has the .selected child: