使用使用標籤時,我的SVG沒有正確呈現。嘗試使用相同的SVG標籤,而不使用使用標籤,這次我運氣好,它正常工作。使用USE標籤時SVG未正確呈現
不幸的是我需要使用USE標記來正確渲染我的SVG。我不知道我做錯了什麼。請參閱下
<!-- 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我一直在使用的工具呈現這個SVG代碼我的代碼,而不是手工編寫代碼
通過 「無法正常渲染」,你是什麼意思?你指的是外面的粗線嗎? –
Firefox至少不支持元素中的元素。將移到元素的外部以解決該問題。 –