I created SVG elements using some basic javascript and string concatenation: http://jsfiddle.net/8d3zqLsf/3/
These SVG elements have a very small distance between them (1px max) and are at an acceptable distance from each other.
When I copy the generated SVG and display it as part of the regular DOM and is not generated when the page loads, it has an odd distance between the SVG elements. http://jsfiddle.net/1n73a8yr/
Note. I checked that the SVG only has a width than the shape inside it, so the extra space does not appear from the SVG.
Why are SVG rendered differently when they are entered when the page loads, and when they appear as part of the DOM? Is there a way to solve this problem without resorting to the left css attribute on svgs with a negative pixel value?
HTML:
<div> <svg width="86.60254037844386" height="100"> <polygon xmlns="http://www.w3.org/2000/svg" id="0" style="fill:#6C6;" points="86.60254037844388,25.000000000000004 86.60254037844388,75 43.30127018922193,100 -7.105427357601002e-15,75 -7.105427357601002e-15,25.000000000000014 43.301270189221924,0 "></polygon></svg> <svg width="86.60254037844386" height="100"> <polygon xmlns="http://www.w3.org/2000/svg" id="0" style="fill:#6C6;" points="86.60254037844388,25.000000000000004 86.60254037844388,75 43.30127018922193,100 -7.105427357601002e-15,75 -7.105427357601002e-15,25.000000000000014 43.301270189221924,0 "></polygon></svg> <svg width="86.60254037844386" height="100"> <polygon xmlns="http://www.w3.org/2000/svg" id="0" style="fill:#6C6;" points="86.60254037844388,25.000000000000004 86.60254037844388,75 43.30127018922193,100 -7.105427357601002e-15,75 -7.105427357601002e-15,25.000000000000014 43.301270189221924,0 "></polygon></svg> </div>
CSS
svg { display:inline-block; margin-left:0px; margin-right:0px; padding-left:0px; padding-right:0px; }
html css html5 svg
Primalwyld
source share