So I have my SVG-circle.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="168" cy="179" r="59" fill="white" />
</svg>
I want it to be 120% when one hover the circle. I tried both with width, height and stroke. Haven't find any solution to make the circle bigger when hovering. Any suggestions?
circle:hover
{
stroke-width:10px;
}
circle:hover
{
height: 120%;
width: 120%;
}
As Phillip suggested in the comment above you can do this with CSS 3 transform.
("-webkit" prefix is for Chrome only)
See https://developer.mozilla.org/en-US/docs/Web/CSS/transform
Here's a working example with CSS transitions too: http://jsbin.com/sozewiso/2
Not sure if the person is still looking for the answers, but for anyone else, it can be done in CSS(3), by setting the transform-origin of the circle to its center.
}
The caveat being CSS is now coupled with dimensions and we have to know the exact center of the circle in the SVG.
I was working on something else and came across this question. I'm doing something similar and using greensock. I animated the scale on a couple circles using Greensock, GSAP. I needed to animate tranformOrigin and the scale property:
Example https://codepen.io/grmdgs/pen/RgjdPv
Greensock https://greensock.com/
I stumbled across this page but wanted to add my own answer that I think is easiest!
Step 1: Add a class (e.g. "myCircle") to your circle
Step 2: In your CSS file you can use "r" as a CSS property!
Step 3 (optional): Feel free to add a transition to make the radius grow smoothly:
Here's a snippet showing it in action:
This should work for you.
jsfiddle
You need to manipulate the radius and this can only be done via javascript:
As per the SVG 1.1 specification you can't style the
r
attribute of an SVG circle using CSS https://www.w3.org/TR/SVG/styling.html#SVGStylingProperties. But you can do:In SVG 2, which is partially supported by some modern browsers, you can style the
r
attribute of circles using CSS. https://www.w3.org/TR/SVG2/styling.html#PresentationAttributes