SVG Horizontal Dashed Circle - html
I'm trying to create the following as an SVG:
I.e. a circle with dashed horizontal lines.
This is the SVG code I have at the moment...generated by Adobe Illustrator:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="165px" height="165px" viewBox="0 0 165 165" enable-background="new 0 0 165 165" xml:space="preserve">
<g>
<circle fill="none" stroke="#000000" stroke-width="9" stroke-miterlimit="23" stroke-dasharray="1.0048,6.0288" cx="82.453" cy="82.563" r="75"/>
</g>
</svg>
But when I open in Chrome the lines seem to be very jagged and some lines are closer then others.
Is there a better way to produce this SVG or shall I simply use a PNG?
Here's a different approach to produce the same appearance which should be more stable across renderers, by using actual line segments rather than very short stroke dashes.
I've used <defs> and <use> to keep the repetition sane — I define four axis-aligned lines around a center and then rotate it by a quarter-circle of even steps. (I changed the scale a bit for the sake of round numbers in my example.)
Note that if zoomed in it will be slightly different: in the original, each dash will be slightly wedge-shaped (due to the curve of the circle), whereas here they will have a constant width since they are just plain line segments.
<svg width="160px" height="160px" viewBox="0 0 160 160">
<defs>
<g id="lines" style="stroke: black;">
<line x1=" 71" x2=" 79" />
<line x1="-71" x2="-79" />
<line y1=" 71" y2=" 79" />
<line y1="-71" y2="-79" />
</g>
</defs>
<g transform="translate(80 80)">
<use xlink:href="#lines" transform="rotate( 0)"/>
<use xlink:href="#lines" transform="rotate( 5)"/>
<use xlink:href="#lines" transform="rotate(10)"/>
<use xlink:href="#lines" transform="rotate(15)"/>
<use xlink:href="#lines" transform="rotate(20)"/>
<use xlink:href="#lines" transform="rotate(25)"/>
<use xlink:href="#lines" transform="rotate(30)"/>
<use xlink:href="#lines" transform="rotate(35)"/>
<use xlink:href="#lines" transform="rotate(40)"/>
<use xlink:href="#lines" transform="rotate(45)"/>
<use xlink:href="#lines" transform="rotate(50)"/>
<use xlink:href="#lines" transform="rotate(55)"/>
<use xlink:href="#lines" transform="rotate(60)"/>
<use xlink:href="#lines" transform="rotate(65)"/>
<use xlink:href="#lines" transform="rotate(70)"/>
<use xlink:href="#lines" transform="rotate(75)"/>
<use xlink:href="#lines" transform="rotate(80)"/>
<use xlink:href="#lines" transform="rotate(85)"/>
</g>
</svg>
This is a SVG-in-HTML fragment — if using it as a standalone SVG document don't forget to put the xmlns back in.
Here is an alternative approach with the same tick count and tick size.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="165px" height="165px" viewBox="0 0 165 165">
<g transform="translate(82.453 82.563)">
<g id="t32">
<g id="t16">
<g id="t8">
<g id="t4">
<g id="t3">
<rect x="70.5" y="-0.5024" width="9" height="1.0048" id="t"/>
<use xlink:href="#t" transform="rotate(5.37)"/>
<use xlink:href="#t" transform="rotate(10.75)"/>
</g>
<use xlink:href="#t" transform="rotate(16.12)"/>
</g>
<use xlink:href="#t4" transform="rotate(21.49)"/>
</g>
<use xlink:href="#t8" transform="rotate(42.99)"/>
</g>
<use xlink:href="#t16" transform="rotate(85.97)"/>
</g>
<use xlink:href="#t32" transform="rotate(171.94)"/>
<use xlink:href="#t3" transform="rotate(343.88)"/>
</g>
</svg>
Related
Safari VoiceOver SVG announces tags inside `<svg />` as separate images
I have an <svg /> element and when I navigate to it in Safari using VoiceOver, the VO announces 6 different images instead of one. Chrome works fine and this element gets announces as an "Unlabelled image": <svg aria-labelledby="imageLabel-10" class="foo" viewBox="0 -60 577 586"> <title id="sometitle-10"></title> <defs> <polygon id="someid" points="1 2 3"> </polygon> <path d="M.123" id="someOtherId"> </path> <mask fill="white" id="oneMoreId"> <use xlink:href="#someHred"> </use> </mask> </defs> <g fill="none" fill-rule="evenodd"> <g style="transform: translateY(-22.0061px); transform-origin: 396.328px 301.186px;"> <path d="M225" fill="#F75647" fill-rule="nonzero" transform="translate(0, 0)"> </path> </g> <g mask="url(#someHref)"> <image height="461" transform="scale(1.1)" width="693" x="60" xlink:href="//cuteCDNPath.jpg" y="-10" style="transform: scale(1.05339); transform-origin: 286.5px 220.5px;"> </image> <use fill="#000" fill-opacity="0.01" xlink:href="#someOtherHref" style="mix-blend-mode: multiply;"> </use> </g> </g> </svg> macOS Mojave 10.14.6 Safari 13.0.5
According to Deque (specifically strategy #5), <svg> tags require a role attribute to be set to img. I am not 100% sure this is the right solution, but adding role="img" did fix my problem. <svg aria-labelledby="imageLabel-10" class="..." role="img" <!-- this was the missing attribute --> viewBox="..." > ... </svg>
Resize svg image
I recently downloaded a linkedin svg image (website: https://www.flaticon.com/free-icon/linkedin_185964?term=linkedin%20logo&page=1&position=15) i have tried endlessly to resize to fit a 16x16 pixel but i can't make it work. I even tried multiple resources online but no success. This is the code: <?xml version="1.0" encoding="iso-8859-1"?> <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve"> <circle style="fill:#4376B1;" cx="256.001" cy="256" r="256"/> <path style="fill:#336699;" d="M511.016,233.634L394.729,117.198c-71.035,9.237-145.27,7.859-216.305,9.511 c-29.306,0-58.613,13.791-53.441,46.545c10.343,65.508,15.515,129.293,3.448,196.525c-1.9,8.545-5.897,17.089-11.117,25.059 L233.48,511.005c7.421,0.646,14.929,0.996,22.519,0.996c141.384,0,256-114.616,256-256 C512.001,248.461,511.656,241.005,511.016,233.634z"/> <path style="fill:#FFFFFF;" d="M376.023,109.468H135.979c-14.643,0-26.51,11.867-26.51,26.51V376.02 c0,14.639,11.867,26.51,26.51,26.51h240.042c14.639,0,26.51-11.871,26.51-26.51V135.978 C402.533,121.335,390.662,109.468,376.023,109.468L376.023,109.468z M200.155,362.517c0,4.263-3.453,7.716-7.716,7.716h-32.837 c-4.263,0-7.716-3.455-7.716-7.716V224.856c0-4.263,3.455-7.716,7.716-7.716h32.839c4.263,0,7.716,3.455,7.716,7.716v137.661 H200.155z M176.02,204.162c-17.23,0-31.196-13.969-31.196-31.201c0-17.229,13.965-31.196,31.196-31.196 c17.232,0,31.198,13.969,31.198,31.196C207.218,190.195,193.251,204.162,176.02,204.162L176.02,204.162z M371.773,363.139 c0,3.918-3.175,7.096-7.09,7.096h-35.242c-3.915,0-7.092-3.177-7.092-7.096v-64.574c0-9.63,2.826-42.21-25.172-42.21 c-21.719,0-26.124,22.3-27.008,32.304v74.478c0,3.918-3.175,7.096-7.094,7.096h-34.082c-3.918,0-7.096-3.177-7.096-7.096V224.234 c0-3.918,3.177-7.096,7.096-7.096h34.082c3.918,0,7.094,3.177,7.094,7.096v12.009c8.054-12.085,20.023-21.416,45.502-21.416 c56.425,0,56.105,52.717,56.105,81.686v66.627H371.773z"/> <path style="fill:#D1D1D1;" d="M376.023,109.468H255.427v107.67h7.647c3.918,0,7.094,3.177,7.094,7.096v12.009 c8.054-12.085,20.023-21.416,45.503-21.416c56.425,0,56.105,52.717,56.105,81.686v66.625c0,3.918-3.175,7.096-7.09,7.096h-35.242 c-3.915,0-7.092-3.177-7.092-7.096v-64.574c0-9.63,2.826-42.21-25.172-42.21c-21.719,0-26.124,22.3-27.008,32.304v74.478 c0,3.918-3.175,7.096-7.094,7.096h-7.647v32.301h120.596c14.639,0,26.51-11.871,26.51-26.51V135.978 C402.533,121.335,390.662,109.468,376.023,109.468z"/> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> </svg>
As suggested by Robert Longson in the comments - you can set the width and height attributes of the SVG node and you will achieve the desired result. <?xml version="1.0" encoding="iso-8859-1"?> <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16" height="16" viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve"> <circle style="fill:#4376B1;" cx="256.001" cy="256" r="256"/> <path style="fill:#336699;" d="M511.016,233.634L394.729,117.198c-71.035,9.237-145.27,7.859-216.305,9.511 c-29.306,0-58.613,13.791-53.441,46.545c10.343,65.508,15.515,129.293,3.448,196.525c-1.9,8.545-5.897,17.089-11.117,25.059 L233.48,511.005c7.421,0.646,14.929,0.996,22.519,0.996c141.384,0,256-114.616,256-256 C512.001,248.461,511.656,241.005,511.016,233.634z"/> <path style="fill:#FFFFFF;" d="M376.023,109.468H135.979c-14.643,0-26.51,11.867-26.51,26.51V376.02 c0,14.639,11.867,26.51,26.51,26.51h240.042c14.639,0,26.51-11.871,26.51-26.51V135.978 C402.533,121.335,390.662,109.468,376.023,109.468L376.023,109.468z M200.155,362.517c0,4.263-3.453,7.716-7.716,7.716h-32.837 c-4.263,0-7.716-3.455-7.716-7.716V224.856c0-4.263,3.455-7.716,7.716-7.716h32.839c4.263,0,7.716,3.455,7.716,7.716v137.661 H200.155z M176.02,204.162c-17.23,0-31.196-13.969-31.196-31.201c0-17.229,13.965-31.196,31.196-31.196 c17.232,0,31.198,13.969,31.198,31.196C207.218,190.195,193.251,204.162,176.02,204.162L176.02,204.162z M371.773,363.139 c0,3.918-3.175,7.096-7.09,7.096h-35.242c-3.915,0-7.092-3.177-7.092-7.096v-64.574c0-9.63,2.826-42.21-25.172-42.21 c-21.719,0-26.124,22.3-27.008,32.304v74.478c0,3.918-3.175,7.096-7.094,7.096h-34.082c-3.918,0-7.096-3.177-7.096-7.096V224.234 c0-3.918,3.177-7.096,7.096-7.096h34.082c3.918,0,7.094,3.177,7.094,7.096v12.009c8.054-12.085,20.023-21.416,45.502-21.416 c56.425,0,56.105,52.717,56.105,81.686v66.627H371.773z"/> <path style="fill:#D1D1D1;" d="M376.023,109.468H255.427v107.67h7.647c3.918,0,7.094,3.177,7.094,7.096v12.009 c8.054-12.085,20.023-21.416,45.503-21.416c56.425,0,56.105,52.717,56.105,81.686v66.625c0,3.918-3.175,7.096-7.09,7.096h-35.242 c-3.915,0-7.092-3.177-7.092-7.096v-64.574c0-9.63,2.826-42.21-25.172-42.21c-21.719,0-26.124,22.3-27.008,32.304v74.478 c0,3.918-3.175,7.096-7.094,7.096h-7.647v32.301h120.596c14.639,0,26.51-11.871,26.51-26.51V135.978 C402.533,121.335,390.662,109.468,376.023,109.468z"/> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> </svg>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px">.....</svg> set fixed width and height for svg tag...
Why does my SVG image get cut out rather than resizing when nested inside another SVG?
I have an SVG that I want to fit in a smaller box, while preserving all ratios. I'm trying to do this by nesting the SVG inside another SVG with smaller width/height and viewbox numbers, but instead of resizing, the image is getting cut out. I've tried nesting the original SVG inside another SVG with different viewbox numbers. Original SVG <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0.0" y="0.0" width="2060.0" height="1340.0" xml:space="preserve" viewBox="0.0 0.0 2060.0 1340.0"> <!-- The artwork image. --> <image dragTarget="true" scaleTarget="true" dragConstraint="canvas-front-rect" scaleConstraint="canvas-front-rect" id="artwork-image" x="5" y="-100.0" width="2400" height="1500" preserveAspectRatio="xMidYMid slice" xlink:href="https://www.printbit.com/wp-content/uploads/2017/06/happy-people.jpg" /> <!-- The "sides" --> <g transform="scale(1, -1) translate(0, -140)" > <use clip-path="url(#clip-path-top)" xlink:href="#artwork-image" /> </g> <g transform="scale(1, -1) translate(0, -2540)" > <use clip-path="url(#clip-path-bottom)" xlink:href="#artwork-image" /> </g> <g transform="scale(-1, 1) translate(-140, 0)" > <use clip-path="url(#clip-path-left)" xlink:href="#artwork-image" /> </g> <g transform="scale(-1, 1) translate(-3980, 0)" > <use clip-path="url(#clip-path-right)" xlink:href="#artwork-image" /> </g> <!-- Constraint information --> <rect id="canvas-front-rect" constraint="gte" x="70.0" y="70.0" width="1920.0" height="1200.0" stroke-width="1" stroke="#0000FF" fill="none" visibility="visible" /> <!-- Clip path definitions for the mirroring --> <defs> <clipPath id="clip-path-top"> <rect x="70.0" y="70.0" width="1920.0" height="70.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-bottom"> <rect x="70.0" y="1200.0" width="1920.0" height="70.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-left"> <rect x="70.0" y="70.0" width="70.0" height="1200.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-right"> <rect x="1920.0" y="70.0" width="70.0" height="1200.0" stroke="#00FF00" fill="none"/></clipPath> </defs> </svg> and I'm trying to nest this inside of <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0.0" y="0.0" width="492.16" height="406.83" xml:space="preserve" viewBox="0.0 0.0 492.16 406.83" ></svg> Expected Result: I want the original SVG to show up as a smaller version of itself, with all ratios preserved. Actual: However, instead of just resizing, the image gets cut out.
Take the width and height off the nested <svg/> element. Then it will adapt to the size of the parent. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0.0" y="0.0" width="492.16" height="406.83" xml:space="preserve" viewBox="0.0 0.0 492.16 406.83" > <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0.0" y="0.0" xml:space="preserve" viewBox="0.0 0.0 2060.0 1340.0"> <!-- The artwork image. --> <image dragTarget="true" scaleTarget="true" dragConstraint="canvas-front-rect" scaleConstraint="canvas-front-rect" id="artwork-image" x="5" y="-100.0" width="2400" height="1500" preserveAspectRatio="xMidYMid slice" xlink:href="https://www.printbit.com/wp-content/uploads/2017/06/happy-people.jpg" /> <!-- The "sides" --> <g transform="scale(1, -1) translate(0, -140)" > <use clip-path="url(#clip-path-top)" xlink:href="#artwork-image" /> </g> <g transform="scale(1, -1) translate(0, -2540)" > <use clip-path="url(#clip-path-bottom)" xlink:href="#artwork-image" /> </g> <g transform="scale(-1, 1) translate(-140, 0)" > <use clip-path="url(#clip-path-left)" xlink:href="#artwork-image" /> </g> <g transform="scale(-1, 1) translate(-3980, 0)" > <use clip-path="url(#clip-path-right)" xlink:href="#artwork-image" /> </g> <!-- Constraint information --> <rect id="canvas-front-rect" constraint="gte" x="70.0" y="70.0" width="1920.0" height="1200.0" stroke-width="1" stroke="#0000FF" fill="none" visibility="visible" /> <!-- Clip path definitions for the mirroring --> <defs> <clipPath id="clip-path-top"> <rect x="70.0" y="70.0" width="1920.0" height="70.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-bottom"> <rect x="70.0" y="1200.0" width="1920.0" height="70.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-left"> <rect x="70.0" y="70.0" width="70.0" height="1200.0" stroke="#00FF00" fill="none"/> </clipPath> <clipPath id="clip-path-right"> <rect x="1920.0" y="70.0" width="70.0" height="1200.0" stroke="#00FF00" fill="none"/></clipPath> </defs> </svg> </svg>
SVG <symbol> won't scale like the others
I'm having trouble with a particular icon not scaling. If you go to this plunker you'll see the very first icon (the cup with the pencil, paint brush and ruler) doesn't respond to the space like every other svg element on the page. I designed them all in Illustrator cc18 using save to generate the svg code. For that particular icon Illustrator gives me this code. <?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="illustration_x5F_icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 79 146" style="enable-background:new 0 0 79 146;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;} </style> <rect id="cup" x="0.6777539" y="67.352684" class="st0" width="77.6444931" height="77.647316"/> <path id="ruler_x5F_shape" class="st0" d="M47.0672798,19.394165v45.8275757h1.1456909v-1.1456909h4.5957031v1.1456909h12.6415443 V19.394165H47.0672798z M48.2129707,22.8312378h4.5957031v1.1456909h-4.5957031V22.8312378z M48.2129707,27.4140015h4.5957031 v1.1456909h-4.5957031V27.4140015z M48.2129707,31.9967651h4.5957031v1.1456909h-4.5957031V31.9967651z M48.2129707,36.5795288 h4.5957031v1.1456909h-4.5957031V36.5795288z M48.2129707,41.1622925h4.5957031v1.1456909h-4.5957031V41.1622925z M48.2129707,45.7450562h4.5957031v1.1456909h-4.5957031V45.7450562z M48.2129707,50.3278198h4.5957031v1.1456909h-4.5957031 V50.3278198z M48.2129707,54.9105835h4.5957031v1.1456909h-4.5957031V54.9105835z M48.2129707,59.4932861h4.5957031v1.1456909 h-4.5957031V59.4932861z M57.404438,62.9303589h-9.1914673V61.784668h9.1914673V62.9303589z M57.404438,58.3475952h-9.1914673 v-1.1456909h9.1914673V58.3475952z M57.404438,53.7648926h-9.1914673v-1.1456909h9.1914673V53.7648926z M57.404438,49.1821289 h-9.1914673V48.036438h9.1914673V49.1821289z M57.404438,44.5993652h-9.1914673v-1.1456909h9.1914673V44.5993652z M57.404438,40.0166016h-9.1914673v-1.1456909h9.1914673V40.0166016z M57.404438,35.4338379h-9.1914673V34.288147h9.1914673 V35.4338379z M57.404438,30.8510742h-9.1914673v-1.1456909h9.1914673V30.8510742z M57.404438,26.2683105h-9.1914673v-1.1456909 h9.1914673V26.2683105z M57.404438,21.6855469h-9.1914673V20.539856h9.1914673V21.6855469z"/> <g id="paint_x5F_brush"> <polygon id="paint_x5F_brush_x5F_shaft" class="st0" points="41.6965485,65.2217407 42.4845047,31.4855003 39.8335533,20.8818035 34.5317612,20.8818035 31.8808079,31.4855003 32.668766,65.2217407 "/> <path id="paint_x5F_brush_x5F_tip" class="st0" d="M40.7088737,19.7361126 c0.7722778-1.1733189,1.775631-3.1726189,1.775631-5.6534939c0-5.1422243-7.0509987-7.2129793-5.3018494-13.0826187 c-0.7470016,0.8390205-5.3017902,7.9498148-5.3017902,13.0826187c0,2.8539448,0.819376,4.633482,1.5470791,5.6534939H40.7088737z" /> </g> <g id="pencil"> <rect id="pencil_x5F_shaft" x="13.5497589" y="38.286869" class="st0" width="13.7482862" height="26.9348717"/> <polygon id="pencil_x5F_tip" class="st0" points="22.6059189,25.2016068 18.2418861,25.2016068 13.7645836,37.1411209 27.0832214,37.1411209 "/> <polygon id="pencil_x5F_lead" class="st0" points="20.4239025,19.3829746 18.456768,24.6287041 22.391037,24.6287041 "/> </g> </svg> I then copy the code and place it in a <symbol> like this <symbol viewbox="0 0 79 146" id="illustration_icon"> <rect id="cup" x="0.6777539" y="67.352684" class="st0" width="77.6444931" height="77.647316"/> <path id="ruler_x5F_shape" class="st0" d="M47.0672798,19.394165v45.8275757h1.1456909v-1.1456909h4.5957031v1.1456909h12.6415443 V19.394165H47.0672798z M48.2129707,22.8312378h4.5957031v1.1456909h-4.5957031V22.8312378z M48.2129707,27.4140015h4.5957031 v1.1456909h-4.5957031V27.4140015z M48.2129707,31.9967651h4.5957031v1.1456909h-4.5957031V31.9967651z M48.2129707,36.5795288 h4.5957031v1.1456909h-4.5957031V36.5795288z M48.2129707,41.1622925h4.5957031v1.1456909h-4.5957031V41.1622925z M48.2129707,45.7450562h4.5957031v1.1456909h-4.5957031V45.7450562z M48.2129707,50.3278198h4.5957031v1.1456909h-4.5957031 V50.3278198z M48.2129707,54.9105835h4.5957031v1.1456909h-4.5957031V54.9105835z M48.2129707,59.4932861h4.5957031v1.1456909 h-4.5957031V59.4932861z M57.404438,62.9303589h-9.1914673V61.784668h9.1914673V62.9303589z M57.404438,58.3475952h-9.1914673 v-1.1456909h9.1914673V58.3475952z M57.404438,53.7648926h-9.1914673v-1.1456909h9.1914673V53.7648926z M57.404438,49.1821289 h-9.1914673V48.036438h9.1914673V49.1821289z M57.404438,44.5993652h-9.1914673v-1.1456909h9.1914673V44.5993652z M57.404438,40.0166016h-9.1914673v-1.1456909h9.1914673V40.0166016z M57.404438,35.4338379h-9.1914673V34.288147h9.1914673 V35.4338379z M57.404438,30.8510742h-9.1914673v-1.1456909h9.1914673V30.8510742z M57.404438,26.2683105h-9.1914673v-1.1456909 h9.1914673V26.2683105z M57.404438,21.6855469h-9.1914673V20.539856h9.1914673V21.6855469z"/> <g id="paint_x5F_brush"> <polygon id="paint_x5F_brush_x5F_shaft" class="st0" points="41.6965485,65.2217407 42.4845047,31.4855003 39.8335533,20.8818035 34.5317612,20.8818035 31.8808079,31.4855003 32.668766,65.2217407 "/> <path id="paint_x5F_brush_x5F_tip" class="st0" d="M40.7088737,19.7361126 c0.7722778-1.1733189,1.775631-3.1726189,1.775631-5.6534939c0-5.1422243-7.0509987-7.2129793-5.3018494-13.0826187 c-0.7470016,0.8390205-5.3017902,7.9498148-5.3017902,13.0826187c0,2.8539448,0.819376,4.633482,1.5470791,5.6534939H40.7088737z" /> </g> <g id="pencil"> <rect id="pencil_x5F_shaft" x="13.5497589" y="38.286869" class="st0" width="13.7482862" height="26.9348717"/> <polygon id="pencil_x5F_tip" class="st0" points="22.6059189,25.2016068 18.2418861,25.2016068 13.7645836,37.1411209 27.0832214,37.1411209 "/> <polygon id="pencil_x5F_lead" class="st0" points="20.4239025,19.3829746 18.456768,24.6287041 22.391037,24.6287041 "/> </g> </symbol> the way I'm using it in the HTML is the same for every icon which is like this <div style="display:grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-auto-rows: 20vh;"> <div style="grid-area:1/1/2/2;"> <svg class="graphicA"> <use xlink:href="assets/symbol_sprite.svg#illustration_icon" /> </svg> </div> <div style="grid-area:1/2/2/3;"> <svg class="graphicA"> <use xlink:href="assets/symbol_sprite.svg#......" /> </svg> </div> <div style="grid-area:1/3/2/4;"> <svg class="graphicA"> <use xlink:href="assets/symbol_sprite.svg#......" /> </svg> </div> <!-- etc. etc. --> </div> You can refer to the plunker for the full code. Does anybody readily see what might be stopping this icon from scaling like the others?
There is a typo in the code, regarding viewBox. <symbol viewbox="0 0 79 146" id="illustration_icon"> should be: <symbol viewBox="0 0 79 146" id="illustration_icon"> Working version
Why is text cutting off in SVG Text on Chrome?
I have a Logo for my new website. The logo looks great in Firefox but as you can see the S on Tomorrow's is cut off in Chrome. Why is this? http://jsfiddle.net/pro5Lgfx/ body { background:black } <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="195px" height="53px" viewBox="0 0 195 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"> <title>Logo</title> <desc>Created with Sketch.</desc> <defs></defs> <g id="Your-Score" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <g id="Desktop-Your-Score" sketch:type="MSLayerGroup" transform="translate(-23.000000, -24.000000)" font-weight="normal" font-family="Gill Sans" letter-spacing="1.16666663" font-size="28" sketch:alignment="middle" fill="#FFFFFF"> <g id="Header" sketch:type="MSTextLayer"> <g id="Primary-Nav-[home]-Copy"> <g id="Logo" transform="translate(23.000000, 18.000000)"> <text id="TOMORROW’S"> <tspan x="0.0328778028" y="26">TOMORROW’S</tspan> <tspan x="36.2975262" y="58">SCORE</tspan> </text> </g> </g> </g> </g> </g> </svg>
DEMO I'm no expert in SVG but After Researching a bit ViewBox is viewBox as the "real" coordinate system, it is the coordinate system used to draw the SVG graphics onto the canvas Yo can specify coordinate to viewbox attribute Source MDN ViewBox Source ViewBox what i came up when i set viewbox width and height to 100% 100% S was visible in chrome as well Update well percentage is supported in viewport(i.e width and height) but not in viewbox,better not put viewbox and viewport unless needed (viewport: width=100% and height=100% will not harm the output) New DEMO Example <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"> body { background: black } <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <svg version="1.1" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"> <title>Logo</title> <desc>Created with Sketch.</desc> <defs></defs> <g id="Your-Score" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <g id="Desktop-Your-Score" sketch:type="MSLayerGroup" transform="translate(-23.000000, -24.000000)" font-weight="normal" font-family="Gill Sans" letter-spacing="1.16666663" font-size="28" sketch:alignment="middle" fill="#FFFFFF"> <g id="Header" sketch:type="MSTextLayer"> <g id="Primary-Nav-[home]-Copy"> <g id="Logo" transform="translate(23.000000, 18.000000)"> <text id="TOMORROW’S"> <tspan x="0.0328778028" y="27">TOMORROW’S</tspan> <tspan x="36.2975262" y="58">SCORE</tspan> </text> </g> </g> </g> </g> </g> </svg>