如何在SVG中包含bootstrap glyphicon

Nag*_*hab 5 css svg

我按照这个SO答案在我的SVG中包含glyphicons,但它不起作用.

这是我想要将图标实现为的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>
Run Code Online (Sandbox Code Playgroud)

我添加到我的css文件中:

svg text{
  font-family: 'Glyphicons Halflings';
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用,它只显示&#e003文本而不是搜索图标,我之后是glyphicon-search图标.我也试过/e003&e003#e003,但没有任何运气.

有没有办法将glyphicons添加到svg组件中?

Pau*_*eau 4

你的实体是错误的。

实体默认为十进制,而不是十六进制。如果要使用十六进制,则必须x#.

此外,实体必须以分号结尾。所以你应该使用的是:

&#xe003;
Run Code Online (Sandbox Code Playgroud)