خرید بک لینک

Vote count: 0

I have 4 SVG buttons as part of a main menu on my personal webpage.

enter image description here

/----------------------------------------------------------------------------------------------------------------------------------/

When one is clicked, all 4 buttons retract to the coers and the respective section is revealed (i.e. AboutMe button --> AboutMe section). enter image description here

Originally I had the SVG objects embedded in an img tag like so:

<img class = "button active" id = "person-icon" src = "resources/main-page-icons/person-icon.svg"/>

I did it like this because I read that when there is no need to animate an SVG it isn't necessary to embed it in an object/embed tag. However, I decided today that I wanted to create a hover effect for the SVG element. I had to change the img tag to an object to allow for styling/animating

<object class = "button active" id = "person-icon" data = "resources/main-page-icons/person-icon.svg" type = "image/svg+xml"></object>

The hover effect works as expected, BUT now I can't click it. Inspecting the element reveals that I'm clicking on the SVG itself and not the object it's embedded in. Wrapping it in a div did not solve the problem either.

Question: Is there a way I can animate the SVG element while handling click events on the object element it's embedded in?

In case someone asks "Why not handle the click event within the SVG element?" I don't think it's possible or would make sense for an SVG element's behavior to influence other elements which is why I handled the click events OUTSIDE of the SVG element (i.e. click 1 button --> other buttons expand, content faded in = bad). Maybe you can, but I didn't think it made sense and it wasn't necessary initially.

Thanks for the help in advance.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 3 ارديبهشت 1395 ساعت: 10:14

صفحه بندی