<svg xmlns="http://www.w3.org/2000/svg">
//设置镜像渐变
<defs>
<radialGradient id="g2" cx="0.5" cy="0.5" r="0.5" fx="0.5" fy="0.5">
<stop offset="0" stop-color="rgb(255,255,250)" />
<stop offset="0.5" stop-color="rgb(255,155,150)" />
<stop offset="1" stop-color="rgb(0,0,0)" />
</defs>
//把渐变应用于矩形
<rect x="0" y="0" width="200" height="150" fill="url(#g2)"></rect>
//设置直线渐变
<defs>
<linearGradient id="g3" fx="0" fy="0.5">
<stop offset="0" stop-color="rgb(255,255,250)" />
<stop offset="0.2" stop-color="rgb(255,155,150)" />
<stop offset="1" stop-color="rgb(0,0,0)" />
</defs>
//把渐变应用于矩形
<rect x="0" y="0" width="200" height="150" fill="url(#g3)"></rect>
</svg>