猿问

文本的背景颜色在SVG

我想为svg的背景着色,text类似于background-colorcss

我只能找到文档fill,为文本本身着色

它甚至可能吗?


摇曳的蔷薇
浏览 1212回答 3
3回答

一只名叫tom的猫

您可以使用过滤器生成背景。<svg width="100%" height="100%">&nbsp; <defs>&nbsp; &nbsp; <filter x="0" y="0" width="1" height="1" id="solid">&nbsp; &nbsp; &nbsp; <feFlood flood-color="yellow"/>&nbsp; &nbsp; &nbsp; <feComposite in="SourceGraphic" operator="xor" />&nbsp; &nbsp; </filter>&nbsp; </defs><text filter="url(#solid)" x="20" y="50" font-size="50">solid background</text></svg>
随时随地看视频慕课网APP
我要回答