【发布时间】:2019-01-25 05:08:07
【问题描述】:
我目前有以下 SVG 代码:
<svg version="1.1" viewBox="0 0 304 202" preserveAspectRatio="xMinYMin meet" class="svg-content" id="container">
<svg id="drawing" x="0" y="0">
<rect x="2" y="1" width="100" height="100" fill="#FBFF82" stroke="#000" stroke-width="2"></rect>
<rect x="2" y="101" width="100" height="100" fill="#EDB1EE" stroke="#000" stroke-width="2"></rect>
<rect x="102" y="1" width="100" height="100" fill="#FBFF82" stroke="#000" stroke-width="2"></rect>
<rect x="102" y="101" width="100" height="100" fill="#EDB1EE" stroke="#000" stroke-width="2"></rect>
<rect x="202" y="1" width="100" height="100" fill="#FBFF82" stroke="#000" stroke-width="2"></rect>
<rect x="202" y="101" width="100" height="100" fill="#EDB1EE" stroke="#000" stroke-width="2"></rect>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" height="32px" x="1" y="1">
<path d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"></path>
</svg>
</svg>
不,我试图将复选标记放置在左上角 (0, 0),但由于使用了 viewBox,它没有发生。图标的原始大小为 512x512,因为它取自 fontawesome。我不能硬编码任何偏移,因为图标的高度会动态变化,除非我可以计算它们。下一个 SVG 尝试绝对定位图标,但没有成功。
【问题讨论】:
标签: css svg position alignment