如何在SVG中为椭圆元素添加轮廓/边框?

4

我是SVG的新手。我想知道在SVG代码中,我可以使用哪个属性来添加椭圆元素的轮廓/边框? 事实上,我正在尝试使用SVG和jQuery制作一个交互式图表,因此当事件发生时,我需要让某些选定的椭圆元素显示特定颜色(如深红色)的实心轮廓。我想知道如何完成这个操作。

谢谢!


边框 ≈ 描边(请参见http://www.w3.org/TR/SVG11/painting.html#StrokeProperties) - Erik Dahlström
2个回答

5
你是不是想表达这样的意思?
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
     width="100%" height="100%">
  <ellipse cx="300" cy="80" rx="100" ry="50"
  fill="yellow" stroke="purple" stroke-width="2"/>
</svg> 

您是指椭圆边缘为紫色吗?还是说您需要在椭圆周围加一个方形边框,需要单独执行以下操作:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
     width="100%" height="100%">
  <ellipse cx="300" cy="80" rx="100" ry="50" fill="yellow"/>
  <rect x="200" y="30" width="200" height="100"
   fill="none" stroke="purple" stroke-width="2"/>
</svg> 

我指的是第一个。谢谢! - assassin

0
在 CSS 中,类似于:
path {
  fill: none;;
  stroke: #646464;
  stroke-width:1px
  stroke-dasharray: 2,2;
  stroke-linejoin: round;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接