<分区>
我可以在 svg 中的矩形坐标中使用百分比值,但不能在多边形中使用。有解决方法吗?
我的意思是,这没问题:
svg {
background: #ADF;
width: 300px;
height: 300px
}
rect {
stroke: black;
fill: #8FF;
}
<svg>
<rect x="10%" y="10%" width="80%" height="70%"/>
</svg>
但这行不通:
svg {
background: #ADF;
width: 300px;
height: 300px
}
polygon {
stroke: black;
fill: #8FF;
}
<svg>
<polygon points="20%,10% 10%,90% 80%,90%"/>
</svg>
Chrome 提示
Error: attribute points: Expected number, "20%,10% 10%,90% 80…".
有什么方法可以用百分比坐标绘制填充多边形吗?