0

I have an SVG image in my code, there are 3 paths in it with IDs #top, #left, #right. I want to swap their colors on hover event over the image container (#block).

<svg>

    #top           /* color 1*/
#left  #right      /* color 2*/

</svg>

Currently I have 3 CSS styles to achieve this:

#block:hover #top
{ fill: color2; }

#block:hover #left
{ fill: color1; }

#block:hover #right
{ fill: color1; }

Is it possible to combine last two to styles into one like:

#block:hover #left, #right
{ fill: color1; }

Or even better, all into one ?

#block:hover
{ 
  @ #left { fill: color1; }
  @ #right{ fill: color1; }
  ....
}

Thank you !

1 Answer 1

1

You can use http://lesscss.org/ or http://sass-lang.com/ . The CSS way would be:

#block:hover #left, #block:hover #right
    { fill: color1; }

and with less:

#block:hover {
    #left, #right {
        fill: color1;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.