我在Angular 8專案中匯入了一張SVG圖片。我用這個HTML生成這個圖片
< div #workflow class="left_pane"/span>> </div>>
而這個TS:
@ViewChild("workflow", {static: true})
公共的mermaidDiv;
當在開發者工具中檢查螢屏時,生成的SVG代碼看起來是這樣的:
< svg id="graphDiv"/span> width="100%" xmlns="http: //www. w3.org/2000/svg"/span> style="max-width: 290.859375px;"/span> viewBox="0 0 290. 859375 421.78125">...</svg>
這就正確地生成了所需的影像。然而,我無法改變這個SVG設定的最大寬度屬性。我在我的component.scss代碼中嘗試了以下方法:
svg#graphDiv {
min-width: 1000px !important;
但這沒有任何作用。我怎樣才能用用戶樣式表覆寫這個xmlns SVG的最大寬度設定?有什么方法可以覆寫 element.style 嗎?
uj5u.com熱心網友回復:
你可以將max-width的值設定為none !important來移除它:
svg#graphDiv {
min-width: 1000px;
max-width: none ! important;
}
< svg id="graphDiv"/span> width="100%" xmlns="http: //www. w3.org/2000/svg" style="max-width: 290. 859375px;" viewBox="0 0 290.859375 421.78125">
< rect x="0" y="0" width="100%" height="100%" fill="銀" />。
</svg>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
這可能是因為你在組件檔案中沒有作業。試著把代碼放到style.scss檔案中。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/320122.html
標籤:
上一篇:我想知道元素名稱的值--e.target.name回傳未定義。
下一篇:防止在藍圈外點擊svg
