【发布时间】:2018-06-26 05:41:55
【问题描述】:
我需要在 svg 中添加背景图片。但我只得到黑色矩形框,图像没有显示。如何添加背景图片?
这是我的代码:
<style>
path {
fill: none;
stroke: #000;
stroke-width: 3px;
stroke-linejoin: round;
stroke-linecap: round;
}
</style>
<svg width="1000" height="700">
<!-- <rect fill="#fff" width="100%" height="100%"></rect> -->
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" x="0" y="0" width="1000" height="700">
<image xlink:href="home/nayana/Documents/Text Editor Files/abstract-hd.jpg" width="600" height="450" />
</pattern>
</defs>
<path d="M5,5 l0,680 l980,0 l0,-680 l-980,0 fill="url(#img1)" />
</svg>
提前致谢
【问题讨论】:
-
那个文件夹名是带空格的,所以我在代码中给了空格
标签: css svg background-image