How to edit text in a SVG file? (not programmatically) - html
I'm trying to edit a .svg file i found in a website template i recently downloaded.
The file code is this one:
<?xml version="1.0" encoding="UTF-8"?>
<svg width="52px" height="10px" viewBox="0 0 52 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Stacked</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" font-size="12" font-family="ProximaNova-Bold, Proxima Nova" font-weight="bold">
<text id="Stacked" fill="#000000">
<tspan x="0" y="9">Stacked</tspan>
</text>
</g>
</svg>
What i want is to simply change the text. I was expecting to do it by changing the inner text of the TSPAN tag you can see at the end of the file. But nothing happens, even if I change text from a SVG editor.
So, my question is: what is the proper way to achieve my goal? Is it even possible to change text in a SVG file?
This is your code, and it should work (please run the code):
svg{border:1px solid;overflow:visible}
<svg width="52px" height="10px" viewBox="0 0 52 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Stacked</title>
<desc>Created with Sketch.</desc>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" font-size="12" font-family="ProximaNova-Bold, Proxima Nova" font-weight="bold">
<text id="Stacked" fill="#000000">
<tspan x="0" y="9">Stacked edited</tspan>
</text>
</g>
</svg>
As an observation: the SVG canvas is very small so large part of the text is not visible unless you add overflow:visiblefor the svg.
Related
How to create hamburger menu icon consisting from single SVG path
The SVG code of Material design Hamburger menu icon: <svg style="width:24px;height:24px" viewBox="0 0 24 24"> <path fill="currentColor" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" /> </svg> However it always could be some reason I can not use the Material Design icon and need to create my own one. But how I can reach such simple code? One path. Tried to draw the similar icon in AbodeXD. The output SVG code was: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="26" height="18" viewBox="0 0 26 18"> <defs> <clipPath id="clip-アートボード_1"> <rect width="26" height="18"/> </clipPath> </defs> <g id="アートボード_1" data-name="アートボード – 1" clip-path="url(#clip-アートボード_1)"> <line id="線_1" data-name="線 1" x2="26" transform="translate(0 0.5)" fill="none" stroke="#000" stroke-width="1"/> <line id="線_2" data-name="線 2" x2="26" transform="translate(0 17.5)" fill="none" stroke="#000" stroke-width="1"/> <line id="線_3" data-name="線 3" x2="26" transform="translate(0 9)" fill="none" stroke="#000" stroke-width="1"/> </g> </svg> The SVG optimization reduced above code to: <svg xmlns="http://www.w3.org/2000/svg" width="26" height="18"> <defs> <clipPath id="a"> <path d="M0 0h26v18H0z"/> </clipPath> </defs> <g data-name="アートボード – 1" clip-path="url(#a)" fill="none" stroke="#000"> <path data-name="線 1" d="M0 .5h26"/> <path data-name="線 2" d="M0 17.5h26"/> <path data-name="線 3" d="M0 9h26"/> </g> </svg> But it a more complicated than Material Design SVG. Also, we can't change the icon color by like fill: red as many other icons.
Path syntax is easy to understand - let's break it down: <path fill="currentColor" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" /> M3,6 - Move the drawing point to coordinates [3,6] H21 - draw a Horizontal line to coordinates [21,Current Y Coordinate (6)] V8 - draw a Vertical line to coordinates [Current X Coordinate (21), 8] H3 - draw a Horizontal line to coordinates [3,Current Y Coordinate (8)] V6 - etc. M3,11 - Move the drawing point to coordinates [3,11] ... etc Z - Draw a line to the start of the current subpath (the coordinates of the last MoveTo - which in this case, doesn't do anything, because we're already at those coordinates) So if you want the hamburger menu to be in a smaller viewBox, you can edit the path by hand like so: <svg style="width:20px;height:20px" viewBox="0 0 20 20"> <path fill="currentColor" d="M1,4 H18 V6 H1 V4 M1,9 H18 V11 H1 V7 M3,14 H18 V16 H1 V14" /> </svg>
Please Use stroke="red" rather than using Fill="red" Please find the Below updated code: <svg xmlns="http://www.w3.org/2000/svg" width="26" height="18"> <defs> <clipPath id="a"> <path d="M0 0h26v18H0z"/> </clipPath> </defs> <g data-name="アートボード – 1" clip-path="url(#a)" fill="none" stroke="red"> <path data-name="線 1" d="M0 .5h26"/> <path data-name="線 2" d="M0 17.5h26"/> <path data-name="線 3" d="M0 9h26"/> </g> </svg>
How can I set the background of SVG to transparent
I created an SVG by Adobe Illustrator and use it in HTML: <?xml version="1.0" encoding="utf-8" ?> <!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 144 22" enable-background="new 0 0 144 22" xml:space="preserve"> <g> <path fill="#FFFFFF" d="M13.4,10.5c0,2.7,0,5.1,0,7.6c-3.7,0-7.4,0-11.1,0c0-0.6,0-1.1,0-1.7c3,0,6,0,9,0c0-1.3,0-2.5,0-3.8 c-3,0-6,0-9,0c0-2.6,0-5,0-7.5c3.7,0,7.3,0,11,0c0,0.6,0,1.1,0,1.8c-3,0-5.9,0-9,0c0,1.2,0,2.4,0,3.6C7.3,10.5,10.3,10.5,13.4,10.5 z" /> <path fill="#FFFFFF" d="M139.8,18.4c0-0.9,0-1.6,0-2.5c-2.7,0-5.4,0-8.2,0c0-2.9,0-5.6,0-8.3c0.7,0,1.3,0,2.1,0c0,2.1,0,4.2,0,6.3 c2.1,0,4,0,6.1,0c0-2.1,0-4.2,0-6.3c0.8,0,1.4,0,2.1,0c0,4.2,0,8.4,0,12.6c-3.5,0-6.8,0-10.3,0c0-0.6,0-1.1,0-1.8 C134.3,18.4,137,18.4,139.8,18.4z" /> <path fill="#FFFFFF" d="M16.6,18.2c0-3.6,0-7,0-10.6c3.4,0,6.7,0,10.2,0c0,1.9,0,3.9,0,5.9c-2.7,0-5.4,0-8.1,0c0,1,0,1.8,0,2.8 c2.7,0,5.4,0,8.2,0c0,0.7,0,1.2,0,1.8C23.4,18.2,20,18.2,16.6,18.2z M18.6,11.6c2.1,0,4.1,0,6.1,0c0-0.7,0-1.4,0-2 c-2.1,0-4.1,0-6.1,0C18.6,10.3,18.6,11,18.6,11.6z" /> <path fill="#FFFFFF" d="M82.7,18.2c-3.3,0-6.5,0-9.8,0c0-3.5,0-7,0-10.6c2.5,0,5.1,0,7.7,0c0-0.9,0.1-1.6,0.1-2.4c0.7,0,1.3,0,2,0 C82.7,9.5,82.7,13.8,82.7,18.2z M80.6,16.2c0-2.3,0-4.4,0-6.6c-1.9,0-3.8,0-5.6,0c0,2.2,0,4.4,0,6.6C76.9,16.2,78.7,16.2,80.6,16.2 z" /> <path fill="#FFFFFF" d="M39.5,18.2c-3.2,0-6.4,0-9.7,0c0-2,0-4,0-6.2c2.5,0,5,0,7.5,0c0-0.9,0-1.6,0-2.4c-1.6,0-3.3,0-5,0 c0-0.7,0-1.3,0-1.9c2.4,0,4.7,0,7.2,0C39.5,11.1,39.5,14.6,39.5,18.2z M37.3,13.9c-1.9,0-3.7,0-5.5,0c0,0.8,0,1.6,0,2.3 c1.9,0,3.7,0,5.5,0C37.3,15.4,37.3,14.7,37.3,13.9z" /> <path fill="#FFFFFF" d="M99,18.1c0-0.5,0-1,0-1.6c2.6,0,5.3,0,8,0c0-1,0-1.8,0-2.8c-2.6,0-5.2,0-7.9,0c0-2.1,0-4,0-6 c3.3,0,6.6,0,10.1,0c0,0.5,0,1,0,1.6c-2.6,0-5.2,0-8,0c0,0.9,0,1.7,0,2.6c2.6,0,5.3,0,8,0c0,2.2,0,4.2,0,6.3 C105.8,18.1,102.4,18.1,99,18.1z" /> <path fill="#FFFFFF" d="M93.9,16.4c0-2.9,0-5.8,0-8.8c0.7,0,1.4,0,2.1,0c0,3.5,0,7,0,10.6c-3.3,0-6.5,0-9.8,0c0-3.5,0-7,0-10.6 c0.6,0,1.2,0,1.9,0c0,2.9,0,5.8,0,8.8C90,16.4,91.8,16.4,93.9,16.4z" /> <path fill="#FFFFFF" d="M60.2,7.6c3.2,0,6.3,0,9.5,0c0,3.5,0,6.9,0,10.5c-0.6,0-1.2,0-2,0c0-2.8,0-5.7,0-8.6c-1.9,0-3.7,0-5.6,0 c0,2.9,0,5.8,0,8.7c-0.7,0-1.3,0-2,0C60.2,14.6,60.2,11.2,60.2,7.6z" /> <path fill="#FFFFFF" d="M119.3,7.5c0,0.7,0,1.3,0,2c-1.4,0-2.7,0-4.1,0c0,2.3,0,4.4,0,6.7c1.3,0,2.6,0,3.9,0c0,0.7,0,1.2,0,1.8 c-2,0-3.9,0-6,0c0-2.8,0-5.6,0-8.4c-0.6-0.1-1-0.1-1.6-0.2c0-0.6,0-1.2,0-1.8c0.5,0,0.9-0.1,1.4-0.1c0-0.8,0.1-1.7,0.1-2.6 c0.6,0,1.2,0,2,0c0,0.8,0,1.7,0,2.6C116.6,7.5,117.9,7.5,119.3,7.5z" /> <path fill="#FFFFFF" d="M124.1,18.1c-0.8,0-1.4,0-2.1,0c0-3.5,0-7,0-10.5c2.3,0,4.5,0,6.9,0c0,0.6,0,1.2,0,1.8c-1.5,0-3.1,0-4.7,0 C124.1,12.4,124.1,15.2,124.1,18.1z" /> <path fill="#FFFFFF" d="M54.9,5.1c0.7,0,1.3,0,2.1,0c0,4.3,0,8.6,0,13.1c-0.7,0-1.3,0-2.1,0C54.9,13.8,54.9,9.4,54.9,5.1z" /> <path fill="#FFFFFF" d="M45.1,4.7c0,4.5,0,9,0,13.5c-0.7,0-1.3,0-2.1,0c0-4.5,0-8.9,0-13.5C43.7,4.7,44.3,4.7,45.1,4.7z" /> </g> </svg> However, it always displays a white background in browser(Chrome ver 75.0.3770.100). I tried to add the SVG into photoshop that ensures its background is transparent. Why it turns out to be this? And how can I solve it? Would you please help me? Thank you.
I found the problem now: whenever I set the container to display: flex. The background will not be transparent. Solution: set a height(such as 100px) to the SVG element,then it will display now.
How to give the svg text property as zooming effect? [duplicate]
I have svg code which contains itemzoom property in text tag but when i opened in adobe illustrator tool it is not showing the text in zoomed effect. please help me to resolve this issue. I have to show the text in itemzoomed format. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="500" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" version="1.0"><rect style="fill:none;stroke:#373435;stroke-width:2.08346" width="500" height="500"/><g id="0.1778128929496472"> <g xmlns="http://www.w3.org/2000/svg" id="0.7911494016479048"> <text xmlns="http://www.w3.org/2000/svg" transform="translate(0.6590909090909091 0.7045454545454546)" fill="#000000" stroke="none" stroke-width="0" stroke-linecap="round" stroke-linejoin="round" x="194" y="420" text-anchor="left" font-size="90.75" font-family="Casablanca" data-textcurve="0" data-itemzoom="1 1" itemzoom="0.5050505050505051 0.543010752688172">Test</text> </g> </svg>
Overlay a svg with a transparent background pattern
Question How can I overlay a transparent image pattern (PNG) over a SVG, while keeping the overlaid image pattern within the SVG's bounds, and keeping the SVG's fill visible? Kind of like how in CSS you can define both background-color and backgroud-image. Eg. background: red url(noise.png) top left repeat; Image Example of what I am looking for In this image, the balloon on the left is the SVG I currently have. What I'm trying to achieve is how the right balloon looks with noise applied to it. Code Example: Here's a code example of what I've tried so far: FULL DEMO: http://staging.kassandrapoon.com/tests/svg/ (Sorry for the non-jsfiddle or code pen example. The background pattern wasn't loading cross domain) SVG with my pattern attempt: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="143px" height="214px" viewBox="0 0 143 214" enable-background="new 0 0 143 214" xml:space="preserve"> <defs> <!-- noise.png --> <style type="text/css"> <![CDATA[ .filtered{ filter: url(#filter); } ]]> </style> <filter id="filter" filterUnits="userSpaceOnUse"> <feImage xlink:href="noise.png" x="0" y="0" width="198" height="193" result="IMAGEFILL"/> <feTile in="IMAGEFILL" result="TILEPATTERN"/> <feComposite operator="in" in="TILEPATTERN" in2="SourceAlpha"/> </filter> </defs> <g> <g class="filtered"> <polygon fill-rule="evenodd" clip-rule="evenodd" fill="#DE3F18" points="90.8,214 53.2,214 47.3,175.9 98.1,175.9 "/> <path fill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1.1,2.4c0.5,1.1,0.9,2.1,1.3,3l0.9,1.8c0.5,1,1,2,1.6,2.9l0.9,1.5c0,0.1,0.1,0.1,0.1,0.2 c0.6,0.9,1.1,1.8,1.6,2.6c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0.3,0.5,0.6,0.9,1,1.4c0.7,0.9,29.4,46.8,29.4,46.8h25.7 c0,0,28.7-45.8,29.4-46.8c0.3-0.5,0.6-0.9,1-1.4c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0.5-0.8,1.1-1.6,1.6-2.6 c0-0.1,0.1-0.1,0.1-0.2l0.9-1.5c0.5-0.9,1-1.9,1.6-2.9l0.9-1.8c0.4-0.8,0.9-1.9,1.3-3c0.3-0.8,0.7-1.6,1-2.4 c0.4-0.9,0.8-1.9,1.1-2.9c0.4-1.2,0.8-2.2,1.2-3.2c0.4-1.6,0.2-3.3,0.4-4.2c1.1-4.6,1.1-11.2,1.1-17.2 C126.1,68.6,126.1,68.5,126.1,68.4C126.1,68.5,126.1,68.4,126.1,68.4z"/> <path fill-rule="evenodd" clip-rule="evenodd" fill="#DE3F18" d="M91.9,57.1c0,43.5-21.6,101-21.6,101s-21.6-57.5-21.6-101 S58.9,0.7,70.4,0.7C79.1,0.7,91.9,13.6,91.9,57.1z"/> <polyline fill="none" stroke="#FC611F" stroke-width="1.8927" stroke-miterlimit="10" points="47.9,175.9 27.8,130 70.6,130 115.2,130.1 96.5,175.9 "/> <line fill="none" stroke="#FC611F" stroke-width="1.8927" stroke-miterlimit="10" x1="73.2" y1="175.9" x2="72.3" y2="130"/> <g> <polygon fill="#DE3F18" points="46.4,158 49.3,158 93.7,158 96.6,158 115.3,130 27.7,130 "/> </g> </g> <g> <g> <path fill="#F9F9EF" d="M102.6,188.6c0,5.5-2.3,7.4-5.1,7.4c-2.8,0-5.1-1.9-5.1-7.4s5.1-12.6,5.1-12.6S102.6,183,102.6,188.6z"/> <path fill="#F9F9EF" d="M77.6,188.6c0,5.5-2.3,7.4-5.1,7.4c-2.8,0-5.1-1.9-5.1-7.4s5.1-12.6,5.1-12.6S77.6,183,77.6,188.6z"/> <path fill="#F9F9EF" d="M52.6,188.6c0,5.5-2.3,7.4-5.1,7.4c-2.8,0-5.1-1.9-5.1-7.4s5.1-12.6,5.1-12.6S52.6,183,52.6,188.6z"/> </g> </g> </g> </svg> I've tried defining a pattern in the SVG like here, but that replaces the existing fill color which I want to keep.
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>