2016-08-03 25 views
0

Font-Symbol in einem SVG fremden Element funktioniert nicht in IE11. Obwohl es in Chrome und Firefox funktioniert. Hier ist mein CodeFont-Symbol in SVG funktioniert nicht in IE 11

var svg = d3.select('#item svg'); 

svg.append('circle') 
    .attr('r', 50) 
    .attr('cx',100) 
    .attr('cy', 100) 
    .style('fill', 'lightgray'); 

svg.append('svg:foreignObject') 
      .attr('x', 100) 
      .attr('y', 100) 
      .append('xhtml:span') 
      .attr('class', ' glyphicon glyphicon-glass') 
      .style('fill', 'white'); 

Wenn Sie this fiddler in IE 11 öffnen, werden Sie kein Symbol auf dem Kreis sehen. Jedoch HTML-Symbol (außerhalb von Svg) funktioniert gut in IE11.

Vielen Dank im Voraus.

+0

IE unterstützt nicht die foreign-Tag. –

Antwort

3

Warum nicht einfach ein <text> Element verwenden?

https://jsfiddle.net/vyz3dgff/2/

var svg = d3.select('#item svg'); 
svg.append('circle') 
    .attr('r', 50) 
    .attr('cx',100) 
    .attr('cy', 100) 
    .style('fill', 'lightgray'); 

svg.append('svg:text') 
     .attr('x', 100) 
     .attr('y', 100) 
     .attr('class', 'glyphicon') // note no glyph selection 
     .attr('text-anchor', 'middle') // horizontal alignment 
     .attr('dy', '0.5em')   // vertical alignment 
     .style('font-size', '48px') 
     .style('fill', 'white') 
     .text("\ue001");    // glyph as defined in the font 
+0

Vielen Dank. Es funktioniert in IE. Btw, wie finde ich den Text '\ ue001' für andere Icons in http://getbootstrap.com/components/? – KhanSharp

+1

Testen Sie das Symbol wie in der Fiddle, dann Inspizieren Sie es (rechtsklicken Sie es, wählen Sie die entsprechende Option) und Sie sollten in der CSS ein 'content: \ e001' oder ähnliches finden. Nimm das und benutze es in '.text()', aber beachte, dass du ein 'u 'hinzufügen musst, also wird' \\001' zu' \ ue001'. –

+0

Perfekt. Du bist der Lebensretter – KhanSharp