我在我的HTML頁面中有一個<svg id="image">,我想將該影像作為邊框。
我在網上找到的是,你可以在CSS中添加:
border-image。url('/some/path/to/image.svg'/span>)。
我想做的是參考位于頁面中的SVG。以下是我的嘗試:
。div {
border: 10px solid;
border-image: url('#round-rect'/span>)。
border-image-slice: 10;
}
svg {
display: none;
}
< div>這應該有圓角</div>
<svg id="round-rect">/span>
< rect width="30" 高度="30"/span> rx="10"/span>>
</svg>/span>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
是否有辦法做到這一點?
uj5u.com熱心網友回復:
你可以將SVG作為一個資料URL。
。div {
border: 10px solid;
border-image: url('data:image/svg xml,<svg viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><rect width="30" height="30" rx="10" fill="red"/></svg> ' /span>) ;
border-image-slice。10;
}
<div> 這應該有圓角</div>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/320098.html
標籤:
上一篇:只對派生類啟用模板化基類
下一篇:旋轉的矩形與文本框不匹配
