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%; }
Code explanation:The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0,0) The r attribute defines the radius of the circle.
There are many Scalable Vector Graphics (SVG), but only certain attributes can be applied as CSS to SVG. Presentation attributes are used to style SVG elements and can be used as CSS properties. Some of these attributes are SVG-only while others are already shared in CSS, such as font-size or opacity .
To create a circle we can set the border-radius on the element. This will create curved corners on the element. If we set it to 50% it will create a circle. If you set a different width and height we will get an oval instead.
The fill property is a presentation attribute used to set the color of a SVG shape.
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:
<circle cx="168" cy="179" r="59" fill="white" stroke="black" onmouseover="evt.target.setAttribute('r', '72');" onmouseout="evt.target.setAttribute('r', '59');"/>
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
Want to only use CSS? Use line
instead of circle
.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <style> .circle { stroke-width: 59; stroke-linecap: round; } .circle:hover { stroke-width: 71; } </style> <line x1="168" y1="179" x2="168" y2="179" stroke="white" class="circle" /> </svg>
http://jsfiddle.net/rLk7rd8b/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With