CSS change d property of

后端 未结 2 997
日久生厌
日久生厌 2020-12-05 11:03

I have a generated svg path code, I want to override it with CSS file to change the svg shape. I could override all the properties except \'d\':

Here is the generate

相关标签:
2条回答
  • 2020-12-05 11:50

    You're almost on the right track here, you just need to set the correct value for the property. It's missing path('..'):

    #map_outer svg path {
        d: path('M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z') !important;
    }
    
    0 讨论(0)
  • 2020-12-05 11:54

    Add a id to your <path d="..."></path> and then the JavaScript code with the new path:

    <svg>
      <path d="..." id="myPath></path>
    </svg>
    <script>
      document.getElementById("myPath").setAttribute("d", "M 0 0 L 0 50 L 50 50");
    </script>
    

    Here's an example:

    <html>
      <body>
        <svg>
          <path d="M 0 0 L 50 0 L 50 50" id="myPath" />
        </svg>
        <script>
          document.getElementById("myPath").setAttribute("d", "M 0 0 L 0 50 L 50 50");
        </script>
      </body>
    </html>

    0 讨论(0)
提交回复
热议问题