2016-11-30 42 views
3

我跟着this SO answer將SVG包含在我的SVG中,但它不起作用。如何在SVG中包含自舉圖形

這就是我要實現的圖標到SVG代碼:

<text 
    ng-attr-x="{{node.width/2}}" 
    ng-attr-y="{{node.height/2+5}}" 
    text-anchor="middle" 
    ng-attr-fill="{{(node.activity.act_task==3 || node.activity.act_task==4)?'#FFFFFF':'#000000';}}"> 
    <tspan x="130" dy="0em">&#e003</tspan> 
    <tspan x="130" dy="1.2em" ng-show="node.activity.act_type == 1 && node.height > 30"><a target="_blank" href="http://{{node.activity.act_info_url}}" style="text-decoration: underline">{{node.activity.act_info}}</a></tspan> 
    </text> 

,我加入到我的CSS文件:

svg text{ 
    font-family: 'Glyphicons Halflings'; 
} 

但沒有奏效,它只是顯示&#e003作爲文本而不是搜索圖標,我之後是glyphicon-search圖標。 我也試過/e003 & &e003#e003但沒有任何運氣。

有沒有一種方法可以在glyphicons中添加到svg組件中?

回答

1

您的實體是錯誤的。

實體在默認情況下是十進制,而不是十六進制。如果要使用十六進制,則必須在#之後放置一個x

此外,實體必須以分號結尾。所以你應該使用的是:

&#xe003; 
+0

這工作,謝謝保羅! –