Come disegnare un rettangolo all'interno di un rettangolo usando SVG?
-
21-12-2019 - |
Domanda
Sto cercando di disegnare un rettangolo all'interno di un rettangolo usando SVG, ma non sto vedendo il rettangolo interno.Qualcuno potrebbe aiutarmi qual è l'errore che sto facendo ??Il codice è come sotto.
<html>
<body>
<h1>My first SVG</h1>
<svg width="700" height="200">
<rect height="100" width="600" style="fill:rgb(255,255,255);stroke-width:3;stroke:rgb(0,0,0)">
<rect height="50" width="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)"/>
</rect>
</svg>
</body>
</html>
.
Grazie in anticipo
Soluzione
Basta disegnare un rettangolo sulla parte superiore di un altro: Saranno disegnati nello stesso ordine in cui scrivi nel tuo codice.
<html>
<body>
<h1>My first SVG</h1>
<svg width="700" height="200">
<rect height="100" width="600" style="fill:rgb(255,255,255);stroke-width:3;stroke:rgb(0,0,0)"></rect>
<rect height="50" width="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)"></rect>
</svg>
</body>
</html>
. Altri suggerimenti
Prova questo codice
<svg width="700" height="200">
<rect height="100" width="200"stroke-width:1 stroke:rgb(0,0,0)"></rect>
<rect height="50" width="100" style="fill:rgb(242,242,242);stroke-width:1;stroke:rgb(0,0,0)</rect>
</svg>
.
Nota: disegnerà rettangoli sovrapposti mentre mantieni l'ordine di RET.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow