mask的形状,fill黑色可见,白色不可见。
<svg width="400" height="300">
<defs>
<mask id="small-rect">
<rect x="0" y="0" width="400" height="300" fill="white"></rect>
<rect width="100" height="100" fill="black" x="200" y="100"></rect>
</mask>
</defs>
<rect id="back" x="0" y="0" width="400" height="300" fill="#d4fcff"></rect>
<rect id="front" x="0" y="0" width="400" height="300" fill="#fcd3db" mask="url(#small-rect)"></rect>
</svg>
来源:https://www.cnblogs.com/-outman/p/12213181.html