/ / SVG no se representa correctamente cuando se usa la etiqueta USE - css, css3, svg

SVG no se representa correctamente cuando se usa la etiqueta USE - css, css3, svg

Tengo un SVG que no se representa correctamente cuando uso la etiqueta use. Intenté usar la misma etiqueta SVG sin usar la etiqueta de uso. Esta vez tuve suerte y funciona correctamente.

Desafortunadamente necesito la etiqueta USE para renderizar mi SVG correctamente. No sé lo que estoy haciendo mal. Consulte mi código a continuación

   <!-- SVG which i"m tring to reuse using use tag--->

<svg xmlns="http://www.w3.org/2000/svg" height="17" width="17" style="display:none">
<symbol id="check">
<defs>
<rect id="addColumn_a" width="16" height="16" y=".996" rx="1"/>
<mask id="addColumn_b" width="16" height="16" x="0" y="0" fill="white">
<use xlink:href="#addColumn_a"/>
</mask>
</defs>
<g fill="none" fill-rule="evenodd" transform="translate(0 -.996)">
<rect width="16" height="1" y="6" fill="#404040"/>
<rect width="16" height="1" y="11" fill="#404040"/>
<rect width="15" height="1" x="3.028" y="8.565" fill="#404040" transform="rotate(-90 10.528 9.065)"/>
<rect width="15.348" height="1" x="-2.141" y="8.554" fill="#5C5C5C" transform="rotate(-90 5.533 9.054)"/>
<use stroke="#404040" stroke-width="2" mask="url(#addColumn_b)" xlink:href="#addColumn_a"/>
<rect width="16" height="6" x="-5" y="5.996" fill="#19AF5C" opacity=".651" transform="rotate(-90 3 8.996)" rx="1"/>
</g>
</symbol>
</svg>

<!-- USE Link refernce which is not rendering SVG properly--->

<svg height="17" width="17">
<use xlink:href="#check"></use>
</svg>


<!-- Same SVG tag just a small change removed symbol tag--->


<svg height="17" width="17">
<defs>
<rect id="a" width="16" height="16" y=".996" rx="1"/>
<mask id="b" width="16" height="16" x="0" y="0" fill="white">
<use xlink:href="#a"/>
</mask>
</defs>
<g fill="none" fill-rule="evenodd" transform="translate(0 -.996)">
<rect width="16" height="1" y="6" fill="#404040"/>
<rect width="16" height="1" y="11" fill="#404040"/>
<rect width="15" height="1" x="3.028" y="8.565" fill="#404040" transform="rotate(-90 10.528 9.065)"/>
<rect width="15.348" height="1" x="-2.141" y="8.554" fill="#5C5C5C" transform="rotate(-90 5.533 9.054)"/>
<use stroke="#404040" stroke-width="2" mask="url(#b)" xlink:href="#a"/>
<rect width="16" height="6" x="-5" y="5.996" fill="#19AF5C" opacity=".651" transform="rotate(-90 3 8.996)" rx="1"/>
</g>
</svg>

P.S He renderizado este código SVG usando herramientas, no un código escrito a mano

Respuestas

1 para la respuesta № 1

Parece un SVG creado con Illustrator.

Por alguna razón, a AI le gusta crear SVG que tenganMáscaras extrañas extrañas y / o clipPaths. Siempre parece estar causando problemas a las personas. Puede ser una buena idea usar un programa diferente para crear íconos. P.ej. Inkscape o Sketch.

Tu problema se debe a alguna interacción extraña.entre la máscara y el símbolo. Renuncié a intentar descifrarlo, porque era más rápido reescribir el icono para deshacerme de la máscara y simplificarla.

Si tienes varios íconos para arreglar, entonces esta solución no te ayuda realmente, supongo. Pero aquí vas de todos modos:

<svg xmlns="http://www.w3.org/2000/svg" height="17" width="17" style="display:none">
<symbol id="check2">
<g fill="none" fill-rule="evenodd">
<rect width="16" height="1" y="5" fill="#404040"/>
<rect width="16" height="1" y="10" fill="#404040"/>
<rect width="1" height="16" x="10" fill="#404040"/>
<rect width="1" height="16" x="5" fill="#5C5C5C"/>
<rect width="15" height="15" x="0.5" y="0.5" rx="0.5" stroke="#404040" stroke-width="1"/>
<rect width="6" height="16" fill="#19AF5C" opacity=".651" rx="1"/>
</g>
</symbol>
</svg>


<svg height="17" width="17">
<use xlink:href="#check2"></use>
</svg>