Adding border to SVG image

后端 未结 2 1904
我在风中等你
我在风中等你 2021-02-18 16:59

Is it possible to wrap a SVG image inside a border (that is - putting a border from CSS around that image) .

相关标签:
2条回答
  • 2021-02-18 17:27

    Draw a <rect> round the image which is fill="none". You can use the stroke of the <rect> as the border.

    0 讨论(0)
  • 2021-02-18 17:37

    Here are some examples, tested in Firefox:

    <svg width="100" height="100" style="border:1px solid black">
    <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
    </svg>
    
    <br><br>
    
    <svg width="300" height="100" style="border:1px solid black">
    <rect width="300" height="100" style="fill:rgb(110, 50, 25); stroke-width:4; stroke:rgb(43, 222, 221);" />
    </svg>
    
    <br><br>
    
    <svg width="170" height="170" style="border:1px solid black">
    <rect x="10" y="10" width="150" height="150" style="fill:blue; stroke:pink; stroke-width:5; fill-opacity:0.1; stroke-opacity:0.9;" />
    </svg>
    

    Hope it helps. :)

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