SVG:设置< text>内容与CSS [英] SVG: Set <text> content with CSS
本文介绍了SVG:设置< text>内容与CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以
<svg>
<text></text>
</svg>
svg text {
content: 'a';
font-family: 'Glyphicon Halflings';
}
?
似乎:before
和:after
伪元素不可用,但是我很高兴由CSS设置我的内容.我可以吗?
It seems :before
and :after
pseudo-elements are not available, but I would be very happy to have my content set by css. Can I?
推荐答案
不能使用纯CSS.需要使用简单的JS:
Not possible using pure CSS. Need to use simple JS:
function changeMyText()
{
document.getElementById('MyText').textContent = "new text";
}
并为您的SVG文本创建ID:
and create ID for your SVG text:
<svg>
<text id="MyText"></text>
</svg>
这篇关于SVG:设置< text>内容与CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文