【发布时间】:2015-08-09 04:33:58
【问题描述】:
我找到了这个 SVG 代码,我想知道如何将它应用到背景图像上?
<svg width="600px" height="600px" viewbox="0 0 600 600">
<defs>
<linearGradient id="alphaLinear">
<stop offset="0%" stop-color="#FFFFFF" stop-opacity="0%" />
<stop offset="100%" stop-color="#FFFFFF" stop-opacity="100%" />
</linearGradient>
<mask id="Mask">
<rect x="0" y="0" width="600" height="600" fill="url(#alphaLinear)" />
</mask>
</defs>
<image xlink:href="/media/images/body-bg.jpg" width="600" height="600" x="0" y="0" preserveAspectRatio="xMinYMin meet" mask="url(#Mask)"/>
</svg>
在<image> 标签中,我将href url 替换为我想要使用的图像。然后我像这样从css调用svg:
body{
background: url('/media/images/gradient.svg') center top no-repeat;
}
似乎什么都没有发生,我得到的只是白色背景。
【问题讨论】: