Jquery 生成带有虚线填充线的SVG矩形

Jquery 生成带有虚线填充线的SVG矩形,jquery,css,svg,dimple.js,Jquery,Css,Svg,Dimple.js,我有一个用酒窝做成的矩形,需要用虚线代替纯色填充框。使用svg、css和/或jquery可以实现这一点吗?矩形在下面 <rect id="dimple-not-working-on-an-associate-s-degree-2008-not-working-on-an-associate-s-degree---" class="dimple-series-0 dimple-bar dimple-not-working-on-an-associate-s-degree dimple-200

我有一个用酒窝做成的矩形,需要用虚线代替纯色填充框。使用svg、css和/或jquery可以实现这一点吗?矩形在下面

<rect id="dimple-not-working-on-an-associate-s-degree-2008-not-working-on-an-associate-s-degree---" class="dimple-series-0 dimple-bar dimple-not-working-on-an-associate-s-degree dimple-2008 dimple-not-working-on-an-associate-s-degree dimple-custom-series-bar dimple-custom-format-1" x="183.5" y="128.4" width="18" height="141.6" opacity="0.8" style="fill: rgb(92, 186, 230); stroke: rgb(77, 156, 192);" fill="#5cbae6" stroke="rgb(77, 156, 192)"></rect>

正如Robert在评论中提到的,您需要做的是使用a填充矩形。步骤很简单:

  • 在SVG中定义一个模式
  • 在图案内部,“画”任何你想成为图案的东西。例如,您需要虚线,因此您可以创建一条只占用图案一部分的线,这样当它重复时,它将看起来是虚线
  • 将属性
    patternUnits
    设置为“userSpaceOnUse”,这样模式将占据应用它的整个元素(就像背景重复一样)
  • 通过引用其id(例如
    fill=“url(#pattern id)”
    fill
    属性中应用模式
在这里,您可以看到一个正在运行的演示:



用图案填充。在图案中,画你想要的任何虚线。你如何用图案填充它?这是svg还是css?非常感谢