簡體   English   中英

SVG中的字體圖標在IE 11中不起作用

[英]Font icon in SVG doesnt work in IE 11

SVG外部元素中的字體圖標在IE11中不起作用。 雖然可以在Chrome和Firefox中使用。 這是我的代碼

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'); 

如果在IE 11中打開此提琴手 ,則圓圈上將看不到任何圖標。 但是,html圖標(在svg之外)在IE11中可以正常工作。

提前致謝。

為什么不只使用<text>元素?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM