用背景图像填充SVG路径元素是否可以设置background-image为了一个SVG<path>元素?例如,如果我设置元素class="wall",CSS样式.wall {fill: red;}很管用,但是.wall{background-image: url(wall.jpg)}不,也不是.wall {background-color: red;}
2 回答

交互式爱情
TA贡献1712条经验 获得超3个赞
<defs> <pattern id="img1" patternUnits="userSpaceOnUse" width="100" height="100"> <image xlink:href="wall.jpg" x="0" y="0" width="100" height="100" /> </pattern></defs>
<path d="M5,50 l0,100 l100,0 l0,-100 l-100,0 M215,100 a50,50 0 1 1 -100,0 50,50 0 1 1 100,0 M265,50 l50,100 l-100,0 l50,-100 z" fill="url(#img1)" />

人到中年有点甜
TA贡献1895条经验 获得超7个赞
chart.append("defs") .append('pattern') .attr('id', 'locked2') .attr('patternUnits', 'userSpaceOnUse') .attr('width', 4) .attr('height', 4) .append("image") .attr("xlink:href", "locked.png") .attr('width', 4) .attr('height', 4);
- 2 回答
- 0 关注
- 1460 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消