我希望 rect 就像 div 顯示塊在哪里?
<svg width="400" height="180">
<rect width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
<rect width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
但它會相互重疊。如何制作另一個矩形并將其包裝在一個 svg 中?
uj5u.com熱心網友回復:
您需要根據是否要水平對齊或垂直對齊來調整 x 和 y屬性。
由于 svg 的高度為 180,因此可能會隱藏垂直定位。你也需要增加它。
水平定位
<svg width="400" height="180">
<rect width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
<rect x="200" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
垂直定位
<svg width="400" height="480">
<rect width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
<rect y="200" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/482074.html
