SCSS color elements from data-attr
Hi All,
I have an
On top of map, I have 4 buttons, with same data-region as in svg. What I want to achieve, is to have both ( area and button) to change its color on hover in both ways: -hovering btn changes area color -hovering area changes also btn color. I was trying to achieve this in plain scss ( no js) but it doesn't work. Does anyone know what I'm doing wrong? Here is my code: https://codepen.io/blberrysmoothie/pen/abxXWVp?editors=1100
<svg>
world map with countries grouped by 4 areas : data-region="".
Each area <g>
has several countries inside them as <path>
.
On hover, all area is turning blue.On top of map, I have 4 buttons, with same data-region as in svg. What I want to achieve, is to have both ( area and button) to change its color on hover in both ways: -hovering btn changes area color -hovering area changes also btn color. I was trying to achieve this in plain scss ( no js) but it doesn't work. Does anyone know what I'm doing wrong? Here is my code: https://codepen.io/blberrysmoothie/pen/abxXWVp?editors=1100
5 Replies
You could try something like this:
@Chris thank you!
Bear in mind that that solution uses :has() so might not work in some browers
right, thanks for pointing this out too! I will search for other solutions as well
why not write it as
.map [data-region="..."]:hover { &, & >* { ...} }
?
you can even have a list and use @each
for the values