我會改變圖標的顏色。如何着色導入svg圖標的md-icon?
我已經進口MdIconRegistry和DomSanitizer
import {MdIconRegistry} from '@angular/material';
import {DomSanitizer} from '@angular/platform-browser';
比增加了SVG到註冊表
constructor (mdIconRegistry: MdIconRegistry, sanitizer: DomSanitizer) {
mdIconRegistry
.addSvgIconInNamespace('img','linkedin',
sanitizer.bypassSecurityTrustResourceUrl('../../assets/icons/linkedin.svg'));
}
在.html文件的調用圖標
<md-icon svgIcon="img:linkedin" class="contacticon" color="primary"></md-icon>
和修改的顏色等參數在CSS:
.contacticon{
padding: 10%;
fill:currentColor;
color: red;
width: 200px;
height: 200px;
font-size:200px;
}
無論color:primary
也不fill: currentColor; color: red
都在工作。
如何更改顏色?
更新:這是對svg
是linkedin.svg你自己添加到您的項目中的文件?你能修改它嗎?發佈(或鏈接)其源代碼可能會有幫助 – ccprog
我從iconflat獲取它。我已更新帖子 – infodev