0

Quero colocar um elemento rect dentro de outro elemento rect. Utilizei o opacity, mas mostra-me sempre um rectangulo. Utilizei o seguinto codigo:

<svg width="400" height="180">
 <g>

  <rect x="50" y="20" width="150" height="150" style="fill:black;stroke:black;stroke-width:2;fill-opacity:0;stroke-opacity:1;">

  <rect x=50 y=30 width=50 height=50>
</g>
</svg>
2
  • Fecha as tags <rect devidamente com /> assim funciona para mim. jsfiddle.net/L4m2ppe0
    – Sergio
    26/12/2014 às 10:33
  • Obrigado @Sergio
    – akm
    26/12/2014 às 10:39

1 Resposta 1

2

Tens de fechar as tags <rect devidamente com /> senão o HTML vai pensar que o segundo rect é descendente do primeiro.

Podes usar <rect ... />:

<svg width="400" height="180">
    <g>
        <rect x="50" y="20" width="150" height="150" style="fill:black;stroke:black;stroke-width:2;fill-opacity:0;stroke-opacity:1;" />
        <rect x=50 y=30 width=50 height=50 />
    </g>
</svg>

ou podes usar <rect ...></rect>:

<svg width="400" height="180">
    <g>
        <rect x="50" y="20" width="150" height="150" style="fill:black;stroke:black;stroke-width:2;fill-opacity:0;stroke-opacity:1;"></rect>
        <rect x=50 y=30 width=50 height=50></rect>
    </g>
</svg>

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .