How to place a svg over other svg using z-index - css
I have some svgs to show teeth, and I´d like to draw a bridge between two them.
I have tried the next in the fiddle link, but the bridge is clipped.
I have many teeth into design and the bridge can be painted in other places between two teeth.
Each tooth can have other painted areas and I need to use z-index to float the bridge between two teeth preserving the originals.
.desabilitado {
fill: black;
stroke: black;
stroke-width: 1px;
opacity: 0.3;
}
.marcadoAzul {
fill: none;
stroke: blue;
stroke-width: 7px;
}
.marcadoVerde {
fill: green;
stroke: black;
stroke-width: 1px;
}
.marcadoMorado {
fill: #CC66CC;
stroke: black;
stroke-width: 1px;
}
.marcadoMarron {
fill: #CC6600;
stroke: black;
stroke-width: 1px;
}
.marcadoAmarillo {
fill: yellow;
stroke: black;
stroke-width: 1px;
}
.marcadoRojo {
fill: red;
stroke: black;
stroke-width: 1px;
}
.marcadoNaranja {
fill: orange;
stroke: black;
stroke-width: 1px;
}
.marcadoTomate {
fill: tomato;
stroke: black;
stroke-width: 1px;
}
.diente {
fill-opacity: 0;
stroke: black;
stroke-width: 1px;
}
.ausente {
fill: none;
opacity: 0;
}
.corona {
fill: none;
opacity: 0;
}
.endodoncia {
fill: none;
opacity: 0;
}
.implante {
fill: none;
opacity: 0;
}
<div>
<svg height="50" width="50" viewBox="0 0 50 50">
<polygon points="10,15 15,10 50,45 45,50" estado="4" value="6" class="ausente" />
<polygon points="45,10 50,15 15,50 10,45" estado="4" value="7" class="ausente" />
<circle cx="30" cy="30" r="16" estado="8" value="8" class="corona" />
<circle cx="30" cy="30" r="20" estado="3" value="9" class="endodoncia" />
<polygon points="50,10 40,10 10,26 10,32 46,32 10,50 20,50 50,36 50,28 14,28" estado="6" value="10" class="implante" />
<g style="z-index:-1">
<defs>
<marker id="arrow" markerWidth="10" markerHeight="10" refX="0" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L9,3 z" fill="#f00" />
</marker>
</defs>
<marker id="circle" markerWidth="4" markerHeight="4" refX="2" refY="2">
<circle cx="2" cy="2" r="1" stroke="none" fill="#f00" />
</marker>
<polyline points="45,30 75,30" fill="none" stroke="#000" stroke-width="2" marker-end="url(#circle)" marker-start="url(#circle)" marker-mid="url(#circle)" />
<polyline points="45,25 75,25" fill="none" stroke="#000" stroke-width="2" marker-end="url(#circle)" marker-start="url(#circle)" marker-mid="url(#circle)" />
</g>
<polygon points="10,10 50,10 40,20 20,20" estado="0" value="1" class="diente" />
<polygon points="50,10 50,50 40,40 40,20" estado="0" value="2" class="diente" />
<polygon points="50,50 10,50 20,40 40,40" estado="0" value="3" class="diente" />
<polygon points="10,50 20,40 20,20 10,10" estado="0" value="4" class="diente" />
<polygon points="20,20 40,20 40,40 20,40" estado="0" value="5" class="diente" />
</svg>
<svg height="50" width="50" viewBox="0 0 50 50">
<polygon points="10,15 15,10 50,45 45,50" estado="4" value="6" class="ausente" />
<polygon points="45,10 50,15 15,50 10,45" estado="4" value="7" class="ausente" />
<circle cx="30" cy="30" r="16" estado="8" value="8" class="corona" />
<circle cx="30" cy="30" r="20" estado="3" value="9" class="endodoncia" />
<polygon points="50,10 40,10 10,26 10,32 46,32 10,50 20,50 50,36 50,28 14,28" estado="6" value="10" class="implante" />
<polygon points="10,10 50,10 40,20 20,20" estado="0" value="1" class="diente" />
<polygon points="50,10 50,50 40,40 40,20" estado="0" value="2" class="diente" />
<polygon points="50,50 10,50 20,40 40,40" estado="0" value="3" class="diente" />
<polygon points="10,50 20,40 20,20 10,10" estado="0" value="4" class="diente" />
<polygon points="20,20 40,20 40,40 20,40" estado="0" value="5" class="diente" />
</svg>
<svg height="50" width="50" viewBox="0 0 50 50">
<polygon points="10,15 15,10 50,45 45,50" estado="4" value="6" class="ausente" />
<polygon points="45,10 50,15 15,50 10,45" estado="4" value="7" class="ausente" />
<circle cx="30" cy="30" r="16" estado="8" value="8" class="corona" />
<circle cx="30" cy="30" r="20" estado="3" value="9" class="endodoncia" />
<polygon points="50,10 40,10 10,26 10,32 46,32 10,50 20,50 50,36 50,28 14,28" estado="6" value="10" class="implante" />
<polygon points="10,10 50,10 40,20 20,20" estado="0" value="1" class="diente" />
<polygon points="50,10 50,50 40,40 40,20" estado="0" value="2" class="diente" />
<polygon points="50,50 10,50 20,40 40,40" estado="0" value="3" class="diente" />
<polygon points="10,50 20,40 20,20 10,10" estado="0" value="4" class="diente" />
<polygon points="20,20 40,20 40,40 20,40" estado="0" value="5" class="diente" />
</svg>
<svg height="50" width="50" viewBox="0 0 50 50">
<polygon points="10,15 15,10 50,45 45,50" estado="4" value="6" class="ausente" />
<polygon points="45,10 50,15 15,50 10,45" estado="4" value="7" class="ausente" />
<circle cx="30" cy="30" r="16" estado="8" value="8" class="corona" />
<circle cx="30" cy="30" r="20" estado="3" value="9" class="endodoncia" />
<polygon points="50,10 40,10 10,26 10,32 46,32 10,50 20,50 50,36 50,28 14,28" estado="6" value="10" class="implante" />
<polygon points="10,10 50,10 40,20 20,20" estado="0" value="1" class="diente" />
<polygon points="50,10 50,50 40,40 40,20" estado="0" value="2" class="diente" />
<polygon points="50,50 10,50 20,40 40,40" estado="0" value="3" class="diente" />
<polygon points="10,50 20,40 20,20 10,10" estado="0" value="4" class="diente" />
<polygon points="20,20 40,20 40,40 20,40" estado="0" value="5" class="diente" />
</svg>
<svg height="50" width="50" viewBox="0 0 50 50">
<polygon points="10,15 15,10 50,45 45,50" estado="4" value="6" class="ausente" />
<polygon points="45,10 50,15 15,50 10,45" estado="4" value="7" class="ausente" />
<circle cx="30" cy="30" r="16" estado="8" value="8" class="corona" />
<circle cx="30" cy="30" r="20" estado="3" value="9" class="endodoncia" />
<polygon points="50,10 40,10 10,26 10,32 46,32 10,50 20,50 50,36 50,28 14,28" estado="6" value="10" class="implante" />
<polygon points="10,10 50,10 40,20 20,20" estado="0" value="1" class="diente" />
<polygon points="50,10 50,50 40,40 40,20" estado="0" value="2" class="diente" />
<polygon points="50,50 10,50 20,40 40,40" estado="0" value="3" class="diente" />
<polygon points="10,50 20,40 20,20 10,10" estado="0" value="4" class="diente" />
<polygon points="20,20 40,20 40,40 20,40" estado="0" value="5" class="diente" />
</svg>
</div>
JSFiddle:
http://jsfiddle.net/3wd1fg0v/1/
The reason the braces are clipping is because you placed an svg 50x50. No path will be able to go beyound that.
You have two choices :
Make one svg that contains everthing. I would recommend using
something like inkspace or illustrator to make it work.
Add seperate svg for each brace
Hopefully this helps, let me know if you have any questions
Related
How do I reuse a nested SVG multiple times, using a different viewBox for each?
My designer has given me an SVG that looks like this: I will be rendering this as a responsive button on a webpage. As the viewport widens, I want this to horizontally expand in a very particular way. This SVG is 250x44, BTW. My thought is to slice it into pieces and glue them back together, like so: Then, at least in theory, I should be able to give each piece its own preserveAspectRatio that defines how each piece should expand to fill up the room available to it. e.g., have the 3rd piece take up all the available room. Unfortunately, I get stuck at the "slice into pieces" part. No matter what I try, I can't seem to get the viewBox of the pieces have the effect I'm looking for. Here's my SVG file: <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 44"> <!-- #default is in <defs>, defined at the bottom of the file. --> <symbol id="bg-1" viewBox="0 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-1" x="0" width="47" height="44" /> <symbol id="bg-2" viewBox="48 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-2" x="48" width="36" height="44" /> <symbol id="bg-3" viewBox="84 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-3" x="84" width="36" height="44" /> <symbol id="bg-4" viewBox="120 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-4" x="120" width="29" height="44" /> <symbol id="bg-5" viewBox="149 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-5" x="149" width="9" height="44" /> <symbol id="bg-6" viewBox="158 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-6" x="158" width="39" height="44" /> <symbol id="bg-7" viewBox="197 0 250 44"> <use href="#default" /> </symbol> <use href="#bg-7" x="197" width="53" height="44" /> <defs> <!-- This is the file my designer gave to me --> <svg id="default"> <defs> <style> .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(#linear-gradient); } .cls-8 { fill: url(#linear-gradient-2); } </style> <linearGradient id="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.2" /> </linearGradient> <linearGradient id="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.15" /> </linearGradient> </defs> <g id="Ingame_Secondary_Button" data-name="Ingame Secondary Button"> <g id="ing2_outershadow" class="cls-1"> <path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /> </g> <path id="ing2_background" class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /> <g id="ing2_pattern" class="cls-4"> <path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /> <path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /> <path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /> <path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /> <path class="cls-5" d="M237.5,37.83h0Z" /> <path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /> <polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /> <path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /> <path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /> <path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /> <path class="cls-5" d="M245.68,15h0l0,0Z" /> <path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /> </g> <path id="ing2_innerborder" class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /> <path id="ing2_gradient" class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /> <path id="ing2_innershadow" class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /> <g id="ing2_outerborder"> <path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /> </g> </g> </svg> </defs> </svg> When I open this file in Firefox, it's rendered like this: When I play with this tool, I feel like I've got the right idea with the viewBox, but no matter what I try, I can't get it to render the pieces I want, where I want. I've tried using nested svgs, uses, and symbols (the latter of which is shown in the current iteration of the file), but I never feel like I'm getting closer to the solution. At this point I'm out of ideas and I think there's just something I don't know that's preventing me from pulling this off. But when I compare my example to the looks of that tool, it seems to me that the symbol.viewBox.x value isn't being respected and I don't know why. To summarize my question, how can I modify this SVG file so that it renders the pieces as shown in the 2nd image? It's okay if each piece has a wonky aspect ratio; I plan to fix that in the next step. For now, I just want to get this parent svg to render these pieces side by side.
First: instead of using the svg element with styles and gradients I prefer to use only the shape leaving the other outside the symbol. Please note that the symbol has a viewBox: <symbol id="default" viewBox="0 0 250 44"> When you use the symbol inside the new symbol the use must have a width and a height. <symbol id="bg-1" viewBox="0 0 250 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-1" x="0" width="50" height="8.8" /> When using bg-1 since you want to use width="50" the height must respect the aspect ratio thus height="8.8" 250/5 = 50; 44/5 = 8.8; The code above is for the uncutted symbol. When you need to cut just the first part of the default you changr the viewBox of the bg-2 symbol: <symbol id="bg-2" viewBox="0 0 50 44"> This will give you the first 50 user units of a total of 250. For the next 50 user units you will need to use viewBox="50 0 50 44" meaning that the fragment is begining at x = 50 and has a width of 50. Next you can use viewBox="100 0 50 44" meaning that the fragment is begining at x = 100 and has a width of 50. and so on... svg { border: solid; } .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(#linear-gradient); } .cls-8 { fill: url(#linear-gradient-2); } <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 55 25"> <!-- #default is in <defs>, defined at the bottom of the file. --> <symbol id="bg-1" viewBox="0 0 250 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-1" x="0" width="50" height="8.8" /> <symbol id="bg-2" viewBox="0 0 50 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-2" x="0" y="12" width="10" height="8.8" /> <symbol id="bg-3" viewBox="50 0 50 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-3" x="10" y="12" width="10" height="8.8" /> <symbol id="bg-4" viewBox="100 0 50 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-4" x="20" y="12" width="10" height="8.8" /> <symbol id="bg-5" viewBox="150 0 50 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-5" x="30" y="12" width="10" height="8.8" /> <symbol id="bg-6" viewBox="200 0 50 44"> <use href="#default" width="250" height="44" /> </symbol> <use href="#bg-6" x="40" y="12" width="10" height="8.8" /> </svg> <!-- This is the file my designer gave to me --> <svg> <defs> <linearGradient id="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.2" /> </linearGradient> <linearGradient id="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.15" /> </linearGradient> </defs> <symbol id="default" viewBox="0 0 250 44"> <path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /> <path id="ing2_background" class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /> <g id="ing2_pattern" class="cls-4"> <path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /> <path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /> <path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /> <path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /> <path class="cls-5" d="M237.5,37.83h0Z" /> <path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /> <polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /> <path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /> <path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /> <path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /> <path class="cls-5" d="M245.68,15h0l0,0Z" /> <path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /> </g> <path id="ing2_innerborder" class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /> <path id="ing2_gradient" class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /> <path id="ing2_innershadow" class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /> <g id="ing2_outerborder"> <path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /> </g> </symbol> </svg>
I wanted to put this at the end of my question, but the source code was so large it wouldn't fit. That's okay though, because this is an answer, just not one I like. Through even more hours of trial and error, I found a solution that works <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 44"> <svg id="bg-1" viewBox="0 0 47 44" x="0" width="47"> <defs> <style> .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(.linear-gradient); } .cls-8 { fill: url(.linear-gradient-2); } </style> <linearGradient class="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.2" /> </linearGradient> <linearGradient class="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.15" /> </linearGradient> </defs> <g class="Ingame_Secondary_Button" data-name="Ingame Secondary Button"> <g class="cls-1"> <path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /> </g> <path class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /> <g class="cls-4"> <path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /> <path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /> <path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /> <path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /> <path class="cls-5" d="M237.5,37.83h0Z" /> <path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /> <polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /> <path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /> <path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /> <path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /> <path class="cls-5" d="M245.68,15h0l0,0Z" /> <path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /> </g> <path class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /> <path class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /> <path class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /> <g> <path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /> </g> </g> </svg> <!-- I'm commenting this out as further proof that it's working the way I want, but I wouldn't comment this out in the real website --> <!-- I'm removing the other nested svgs, otherwise my post is too large for SO to accept. --> <svg id="bg-7" viewBox="197 0 53 44" x="197" width="53"> <defs> <style> .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(.linear-gradient); } .cls-8 { fill: url(.linear-gradient-2); } </style> <linearGradient class="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.2" /> </linearGradient> <linearGradient class="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.15" /> </linearGradient> </defs> <g class="Ingame_Secondary_Button" data-name="Ingame Secondary Button"> <g class="cls-1"> <path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /> </g> <path class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /> <g class="cls-4"> <path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /> <path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /> <path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /> <path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /> <path class="cls-5" d="M237.5,37.83h0Z" /> <path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /> <polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /> <path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /> <path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /> <path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /> <path class="cls-5" d="M245.68,15h0l0,0Z" /> <path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /> </g> <path class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /> <path class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /> <path class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /> <g> <path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /> </g> </g> </svg> </svg> But I hate it because: I have to heavily modify the SVG my designer gave me. For example, I converted all the ids to classes. (Maybe that was completely unnecessary, but I was throwing darts at the wall while figuring out how to get it to its current state.) If they want to change the look of the button, I have to make all these modifications over again multiplied by the number of pieces. I don't understand why it works whereas my first example didn't. Compared to my non-working version, the file is massive. Is there some way to only use the designer's SVG once in my code with minimal modification?
After even more hours of trial and error, I've found a solution that doesn't require copying and pasting my designer's SVG code for each piece. I don't really understand why the current code works whereas all my other attempts failed, but that's a question for another post (that I plan to link to after I create it). Here is the working code: <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 44"> <!-- #Ingame_Secondary_Button is defined at the bottom of the file. --> <symbol id="bg-1" viewBox="0 0 47 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-1" x="0" width="47" /> <symbol id="bg-2" viewBox="48 0 36 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-2" x="47" width="37" /> <!-- I'm commenting this out as evidence that these are pieces of the SVG (as opposed to the whole SVG overlapping itself x times) --> <!-- <symbol id="bg-3" viewBox="84 0 36 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-3" x="84" width="36" /> --> <symbol id="bg-4" viewBox="120 0 29 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-4" x="120" width="29" /> <symbol id="bg-5" viewBox="149 0 9 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-5" x="149" width="9" /> <symbol id="bg-6" viewBox="158 0 39 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-6" x="158" width="39" /> <symbol id="bg-7" viewBox="197 0 53 44"> <use href="#Ingame_Secondary_Button"/> </symbol> <use href="#bg-7" x="197" width="53" /> <!-- This is the file my designer gave to me --> <symbol id="default"> <defs> <style> .cls-1, .cls-8 { opacity: 0.6; } .cls-2 { fill: #25180c; } .cls-3 { fill: #fcf9eb; } .cls-4 { opacity: 0.02; } .cls-5 { fill: #956131; } .cls-6 { fill: none; stroke: #724141; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1px; stroke-dasharray: 69.96 2.5 1 2.5 1 2.5; opacity: 0.3; } .cls-7 { opacity: 0.5; fill: url(#linear-gradient); } .cls-8 { fill: url(#linear-gradient-2); } </style> <linearGradient id="linear-gradient" x1="125.64" y1="27.26" x2="125.64" y2="2" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.2" /> </linearGradient> <linearGradient id="linear-gradient-2" x1="111.9" y1="50.47" x2="115.6" y2="8.24" gradientUnits="userSpaceOnUse"> <stop offset="0" stop-color="#956131" stop-opacity="0" /> <stop offset="1" stop-color="#956131" stop-opacity="0.15" /> </linearGradient> </defs> <g id="Ingame_Secondary_Button" data-name="Ingame Secondary Button"> <g id="ing2_outershadow" class="cls-1"> <path class="cls-2" d="M234.3,3.16H26.36a2.55,2.55,0,0,0-2.24,1.32,4.75,4.75,0,0,1-.61.94,1.37,1.37,0,0,1-1.28.38,1.88,1.88,0,0,1-.65-.39L19.78,4a3.83,3.83,0,0,0-2.38-.83H1.91A1.89,1.89,0,0,0,0,5V40.29A3.76,3.76,0,0,0,3.81,44H148.72a4,4,0,0,0,1.14-.17l1.61-.47a8,8,0,0,1,3.32-.39,2.73,2.73,0,0,1,1,.4,4.1,4.1,0,0,0,2.12.63h76.39a1.56,1.56,0,0,0,1.07-.43c7.19-7,11.58-13.24,14.48-19.09a1.93,1.93,0,0,0,0-1.78c-5.16-9.34-9.92-15.22-14.46-19.17A1.51,1.51,0,0,0,234.3,3.16Z" /> </g> <path id="ing2_background" class="cls-3" d="M3.81,41H148.72a2.72,2.72,0,0,0,.84-.13c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h76.39a.58.58,0,0,0,.37-.15,72.13,72.13,0,0,0,14.29-19.36,1.08,1.08,0,0,0,0-.93c-4.65-8.66-9.31-15-14.25-19.44A.46.46,0,0,0,234.3,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41Z" /> <g id="ing2_pattern" class="cls-4"> <path class="cls-5" d="M61.11,5.25H50.84L49,6.33a221.18,221.18,0,0,1-20,10A139.08,139.08,0,0,1,5.24,24.21v6.44A182.55,182.55,0,0,0,31,20.92C41.33,16.15,51.19,10.54,61.11,5.25Z" /> <path class="cls-5" d="M29.81,5.25H28.12a.47.47,0,0,0-.38.19,6.06,6.06,0,0,1-.59.66,6.59,6.59,0,0,1-6.44,1.64,7.15,7.15,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11H10.15c-1.63.43-3.26.83-4.91,1.18v8.46l1.67-.43A105.92,105.92,0,0,0,29.81,5.25Z" /> <path class="cls-5" d="M75.9,20.29c9.42-5.44,19-10.41,29.31-13.25a78.43,78.43,0,0,1,8.15-1.79H94.79A183.6,183.6,0,0,0,73,15L58.4,22.48c-4.88,2.41-9.75,4.77-14.72,6.86-2.48,1-5,2.05-7.48,3-1.25.48-2.52.9-3.79,1.34s-2.53.87-3.8,1.26c-2,.64-4,1.25-6.08,1.82H47.19C57.08,31.58,66.48,25.75,75.9,20.29Z" /> <path class="cls-5" d="M200,27.22A319.47,319.47,0,0,0,169.61,9.79a92.1,92.1,0,0,0-10.5-4.54h-17.4a78.67,78.67,0,0,1,25.51,9.09,215.09,215.09,0,0,1,28.41,18.88c1.46,1.18,3,2.36,4.44,3.53h16L213.8,35.6C209.13,33,204.52,30.2,200,27.22Z" /> <path class="cls-5" d="M237.5,37.83h0Z" /> <path class="cls-5" d="M213.8,16.09c-2.56-1.86-5-3.79-7.7-5.55l-3.95-2.67c-1.31-.9-2.72-1.68-4.09-2.51l-.18-.11H181.13C190.34,10,201,15.76,209.49,21.94c2.51,1.8,5,3.71,7.49,5.55L224.59,33c1.79,1.23,3.54,2.49,5.33,3.72h2.55a.52.52,0,0,0,.37-.16q1.74-1.8,3.28-3.6-3.75-2.7-7.46-5.49C223.76,23.7,218.85,19.86,213.8,16.09Z" /> <polygon class="cls-5" points="239.58 35.47 239.58 35.47 239.58 35.47 239.58 35.47" /> <path class="cls-5" d="M146.35,16.24a52.33,52.33,0,0,0-12.56-2.95,65.68,65.68,0,0,0-12.78.19,63,63,0,0,0-12.44,2.76,70.65,70.65,0,0,0-11.64,5.12A130.2,130.2,0,0,0,76.47,35.9l-1,.85h9.3A88.7,88.7,0,0,1,99.37,25.64a54,54,0,0,1,22.15-7.57,52.77,52.77,0,0,1,11.72,0,42.13,42.13,0,0,1,11.15,3.13A72.43,72.43,0,0,1,164,34.33c.88.79,1.73,1.61,2.58,2.42h12.75c-3.48-2.82-7-5.6-10.7-8.23C161.74,23.65,154.43,19.17,146.35,16.24Z" /> <path class="cls-5" d="M134.55,27.28a24.77,24.77,0,0,0-4.05-1.15,18.43,18.43,0,0,0-2.11-.27c-.7-.05-1.36-.06-2-.05a29.3,29.3,0,0,0-4.06.36,27.67,27.67,0,0,0-7.68,2.56A38.94,38.94,0,0,0,108,33.09c-1.43,1.17-2.79,2.4-4.1,3.66h7.36a22.78,22.78,0,0,1,11.79-6,16.65,16.65,0,0,1,3.31-.22c.55,0,1.13.05,1.65.11a11.72,11.72,0,0,1,1.55.28,17,17,0,0,1,5.86,2.74,32.48,32.48,0,0,1,3.68,3.1h9.3a54.16,54.16,0,0,0-10.13-7.69A28.5,28.5,0,0,0,134.55,27.28Z" /> <path class="cls-5" d="M220.07,5.25c6.46,4.74,13,9.45,19.85,13.79,1.37.87,2.76,1.73,4.15,2.57l.14-.25a.5.5,0,0,0,0-.49,81.5,81.5,0,0,0-6.94-10.66q-4.09-2.43-8.16-5Z" /> <path class="cls-5" d="M245.68,15h0l0,0Z" /> <path class="cls-5" d="M239.58,35.47c-.67.79-1.36,1.57-2.08,2.36C238.22,37,238.91,36.26,239.58,35.47Z" /> </g> <path id="ing2_innerborder" class="cls-6" d="M232.63,5.25H28.12a.51.51,0,0,0-.39.19,5.08,5.08,0,0,1-.58.66,6.59,6.59,0,0,1-6.44,1.64,7.25,7.25,0,0,1-2.44-1.35L17,5.36a.49.49,0,0,0-.31-.11h-11a.5.5,0,0,0-.5.5v30.5a.5.5,0,0,0,.5.5H148.42l.15,0,1.51-.45a12.63,12.63,0,0,1,5.57-.52,7.44,7.44,0,0,1,2.52.93.48.48,0,0,0,.24.06h74.06a.52.52,0,0,0,.37-.16,67.69,67.69,0,0,0,11.37-15.23.5.5,0,0,0,0-.49C240.49,14.2,236.8,9.11,233,5.39A.5.5,0,0,0,232.63,5.25Z" /> <path id="ing2_gradient" class="cls-7" d="M246.94,27.26q1.44-2.37,2.6-4.77a1,1,0,0,0,0-.92c-4.65-8.67-9.31-15-14.24-19.45a.48.48,0,0,0-.33-.12H27a1.55,1.55,0,0,0-1.35.82A4.64,4.64,0,0,1,24.84,4a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58L19.78,2.62A2.77,2.77,0,0,0,18,2H2.54a.9.9,0,0,0-.9.91V27.26Z" /> <path id="ing2_innershadow" class="cls-8" d="M149.56,40.87c.6-.19,1.18-.36,1.64-.49a10.87,10.87,0,0,1,2.87-.5A5.42,5.42,0,0,1,155,40a3.55,3.55,0,0,1,1.32.56,3,3,0,0,0,1.58.49h70c-13.72-5.86-30.11-15.3-30.11-15.3l-78-7.51-34.86-.13S61.17,9.64,32.9,1H26.36A1.53,1.53,0,0,0,25,1.82,4.57,4.57,0,0,1,24.2,3a2.31,2.31,0,0,1-2.26.63,2.78,2.78,0,0,1-1-.58l-1.8-1.47A2.81,2.81,0,0,0,17.4,1H1.91A.91.91,0,0,0,1,1.91V38.18A2.81,2.81,0,0,0,3.81,41H148.72A2.72,2.72,0,0,0,149.56,40.87Z" /> <g id="ing2_outerborder"> <path class="cls-5" d="M26.32,1.44h0M234.12,2c4.79,4.33,9.33,10.56,13.88,19.06A70.67,70.67,0,0,1,234.05,40H157.3a5,5,0,0,0-2.18-1,6,6,0,0,0-1.05-.09,11.68,11.68,0,0,0-3.13.54c-.5.14-1.15.33-1.95.58H2V2H18l2.29,1.86a3.94,3.94,0,0,0,1.33.76,2.87,2.87,0,0,0,.87.13,3.49,3.49,0,0,0,2.38-1A6.39,6.39,0,0,0,26,2H234.12m.37-2H25.42a1,1,0,0,0-.9.56,9.75,9.75,0,0,1-1,1.76,1.45,1.45,0,0,1-1,.43,1,1,0,0,1-.29,0,1.91,1.91,0,0,1-.65-.4L19,.22A1,1,0,0,0,18.39,0H1A1,1,0,0,0,0,1V41a1,1,0,0,0,1,1H149.15a1,1,0,0,0,.3,0c.74-.23,1.46-.45,2-.6a9.75,9.75,0,0,1,2.6-.47,4.37,4.37,0,0,1,.72.06,3.63,3.63,0,0,1,1.53.83A1,1,0,0,0,157,42h77.5a1,1,0,0,0,.71-.3c7.28-7.25,11.7-13.71,14.63-19.77a2,2,0,0,0-.05-1.85c-5.2-9.7-10-15.77-14.59-19.83a1,1,0,0,0-.67-.25Z" /> </g> </g> </symbol> </svg> The major change is my symbol.use.href now refers to a <g id="Ingame_Secondary_Button" ...> inside the #default symbol. No matter what I tried, I couldn't find a solution unless I bypassed #default. Fortunately, there's no visual difference between #default and #Ingame_Secondary_Button. I've read that useing a symbol creates a new viewBox. I think that's related to why I couldn't get it to work with <use href="#default"/>, but this additional viewBox wasn't news to me; I was attempting to account for it the whole time. There is one more major change: I removed the coordinates from <use href="#Ingame_Secondary_Button"/>. Here is my previous answer, and I think it's worth keeping around, even though it's not ideal, because it shows another way to solve the problem.
How to correctly place an image outside the container, and make them adaptive, HTML/CSS?
Maket link: https://www.figma.com/file/hYoPHDHOzzgzEPo4crMmy1/UH15U7CD4WZkbhcW?node-id=2%3A334 Project link: https://plupiks.github.io/Real-Estate-LandingPage/ I have a layout, it has an image of a building. This image is outside of the container. I was able to take the image out of the container, but I can’t adapt it anymore. If I give the image width: 100%; height: auto; , its dimensions no longer correspond to those specified in the layout. The question is, how to move images outside the container so that they can then be adapted without changing the original image dimensions? Worked with preprocessor SCSS. <div class="hero"> <div class="container"> <div class="hero--wrapper"> <div class="hero--blok-left"> <div class="hero--descr">Welcome to Besnik Agency</div> <h1 class="hero--title">Discover a place you’ll love to live.</h1> <p class="hero--subtitle"> Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search </p> <button class="button hero--button">More About Us</button> </div> <div class="hero--block-right"> <div class="hero--img"> <svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" /> <path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" /> <path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" /> <path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" /> <path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" /> <path d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z" fill="#0E173D" /> <path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" /> <path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" /> <path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" /> <path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" /> <path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" /> <path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" /> <path d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z" fill="#CFDEF3" /> <path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" /> <rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" /> <rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" /> <rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" /> <path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" /> <path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" /> <path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" /> <path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" /> <rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" /> <path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" /> <path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" /> <path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" /> <path d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#1F326B" /> <path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" /> <path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" /> <rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" /> <rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" /> <rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" /> <path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" /> <rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" /> <rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" /> <rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <path d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322" stroke="#A3BDFF" stroke-width="4" /> <rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" /> <path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" /> <path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" /> <path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" /> <rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" /> <path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" /> <path d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z" fill="#0D0808" /> <path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" /> <path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" /> <path d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422" stroke="black" stroke-width="4" /> <path d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5" stroke="black" stroke-width="3" /> <circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" /> <circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" /> <circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" /> <circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" /> <path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" /> <path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" /> <path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" /> <path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" /> <path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" /> <path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" /> </svg> </div> </div> </div> </div> </div> .hero { position: relative; background-color: $blueElis; font-size: 16px; } .hero--wrapper { display: flex; column-gap: 4.1875em; padding-top: 7.125em; } .hero--blok-left { flex: 0 0 50.37%; margin-top: 5.6875em; } .hero--descr { margin-bottom: 0.444em; #include SWCL(1.125em, 500, $pigeonBlue, 1.6875); } .hero--title { margin-bottom: 0.46875em; #include SWCL(4em, 700, $darkBlue, 1.1875); } .hero--subtitle { #include SWCL(1.125em, 400, $marengo, 2); margin-bottom: 2.222em; } .hero--button { } .hero--block-right { display: flex; align-items: flex-end; } .hero--img { width: 36.5em; height: auto; & svg { max-width: 100%; height: auto; } } // Adaptive #media only screen and (max-width: 1024px) { .header { font-size: 14px; } }
.hero--img { width: 100%; height: auto; max-width: 36.5em; }
.hero { position: relative; background-color: $blueElis; font-size: 16px; } .hero--wrapper { display: flex; column-gap: 4.1875em; padding-top: 7.125em; } .hero--blok-left { flex: 0 0 50.37%; margin-top: 5.6875em; } .hero--descr { margin-bottom: 0.444em; #include SWCL(1.125em, 500, $pigeonBlue, 1.6875); } .hero--title { margin-bottom: 0.46875em; #include SWCL(4em, 700, $darkBlue, 1.1875); } .hero--subtitle { #include SWCL(1.125em, 400, $marengo, 2); margin-bottom: 2.222em; } .hero--button {} .hero--block-right { display: flex; align-items: flex-end; } svg { width: 100%; height: 100%; max-width:584px; max-height:620px; } // Adaptive #media only screen and (max-width: 1024px) { .header { font-size: 14px; } } <div class="hero"> <div class="container"> <div class="hero--wrapper"> <div class="hero--blok-left"> <div class="hero--descr">Welcome to Besnik Agency</div> <h1 class="hero--title">Discover a place you’ll love to live.</h1> <p class="hero--subtitle"> Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search </p> <button class="button hero--button">More About Us</button> </div> <div class="hero--block-right"> <div class="heroimg"> <svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" /> <path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" /> <path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" /> <path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" /> <path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" /> <path d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z" fill="#0E173D" /> <path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" /> <path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" /> <path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" /> <path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" /> <path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" /> <path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" /> <path d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z" fill="#CFDEF3" /> <path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" /> <rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" /> <rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" /> <rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" /> <path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" /> <path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" /> <path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" /> <path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" /> <rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" /> <path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" /> <path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" /> <path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" /> <path d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#1F326B" /> <path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" /> <path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" /> <rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" /> <rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" /> <rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" /> <path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" /> <rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" /> <rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" /> <rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" /> <path d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322" stroke="#A3BDFF" stroke-width="4" /> <rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" /> <path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" /> <path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" /> <path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" /> <rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" /> <rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" /> <path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" /> <path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" /> <path d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z" fill="#0D0808" /> <path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" /> <path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" /> <path d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422" stroke="black" stroke-width="4" /> <path d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5" stroke="black" stroke-width="3" /> <circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" /> <circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" /> <circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" /> <circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" /> <circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" /> <circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" /> <path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" /> <path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" /> <path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" /> <path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" /> <path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" /> <path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" /> </svg> </div> </div> </div> </div> </div> Like the above?(run snippet) Idea: Use percentage (100%) as width,height of svg
As an easy workaround you could set your background-size using a relative unit like %, vw, vmin or vmax like so: /* small devices */ .hero{ background-size: 50%; } /* large devices */ #media (min-width:1024px){ .hero{ background-size: 36.5em 38.75em; } } You original background size will be applied for viewports larger than 1024px. You will of course need to tweak the values to get your desired results.
How to make a star or a cross using an svg ellipse?
I am creating an ellipse in svg. In this ellipse I am trying to give a shape like a star or cross. I can not use anything else other than ellipse. This is what I have done so far. <ellipse cx="96" cy="126" rx="5" ry="5" fill="#EF4444" stroke="#EF4444" stroke-width="19" stroke-dasharray="4" opacity="1" transform="translate(139 50)"></ellipse> All I did is, added the stroke-dasharray="4" and it became like a cross. But it is not proper yet. Can anyone help me on this please. This is how it looks like now. Which is not a star or a cross.
I am not entirely sure what you mean by I can not use anything else other than ellipse If you strictly follow that restriction, then your request would seem close to impossible. Your first attempt is a nice idea, but unfortunately it may have issues. Creating circles or ellipses with stroke widths that are greater than the radius (technically, more than double the radius), can not always be trusted to render correctly. The approach that Robert suggested is better and more flexible, but will require the use of SVG elements other than <ellipse> For example take the following design. svg { width: 400px; } <svg viewBox="0 0 100 70"> <ellipse cx="50" cy="35" rx="40" ry="28" fill="none" stroke="black" stroke-width="1"/> <g class="cross"> <rect x="0" y="20" width="100" height="30" transform="rotate(35, 50,35)"/> <rect x="0" y="20" width="100" height="30" transform="rotate(-35, 50,35)"/> </g> </svg> If we turn the ellipse into a clip path, and apply it to the cross, we get this: svg { width: 400px; } <svg viewBox="0 0 100 70"> <defs> <clipPath id="oval"> <ellipse cx="50" cy="35" rx="40" ry="28"/> </clipPath> </defs> <g class="cross" clip-path="url(#oval)"> <rect x="0" y="20" width="100" height="30" transform="rotate(35, 50,35)"/> <rect x="0" y="20" width="100" height="30" transform="rotate(-35, 50,35)"/> </g> </svg> You can make the cross part look however you like, and still clip it with the ellipse.
Another idea. Cut a cross from a circle using four ellipses <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="400" viewBox="0 0 400 400" > <circle cx="200" cy="200" r="100" fill="crimson" /> <circle cx="200" cy="200" r="40" fill="none" stroke="black" /> <circle cx="200" cy="200" r="2" fill="black" /> <polyline fill="none" stroke="black" points="0,0 400,400" /> <polyline fill="none" stroke="black" points="0,400 400,0" /> <ellipse transform="rotate(45 100 125)" cx="80" cy="107" rx="102" ry="50" fill="gold" opacity="0.5" /> <ellipse transform="translate(125 -20) rotate(135 100 125)" cx="45" cy="80" rx="100" ry="50" fill="gold" opacity="0.5" /> <ellipse transform="translate(125 -20) rotate(225 100 125)" cx="-90" cy="40" rx="100" ry="50" fill="gold" opacity="0.5" /> <ellipse transform="translate(125 -20) rotate(315 100 125)" cx="-125" cy="175" rx="100" ry="50" fill="gold" opacity="0.5" /> </svg> Then you can use these ellipses as a mask. .container { width:75vw; height:auto; } <div class="container"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 50 400 400" preserveAspectRatio="xMinYMin meet"> <defs> <mask id="msk"> <rect width="100%" height="100%" fill="white" /> <g id="group" fill="black"> <ellipse transform="rotate(45 100 125)" cx="80" cy="107" rx="102" ry="50" /> <ellipse transform="translate(125 -20) rotate(135 100 125)" cx="45" cy="80" rx="100" ry="50" /> <ellipse transform="translate(125 -20) rotate(225 100 125)" cx="-90" cy="40" rx="100" ry="50" /> <ellipse transform="translate(125 -20) rotate(315 100 125)" cx="-125" cy="175" rx="100" ry="50" /> </g> </mask> </defs> <image href="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Foro_Romano.jpg/1200px-Foro_Romano.jpg " width="100%" height="100%" /> <circle mask="url(#msk)" cx="200" cy="200" r="100" fill="crimson" opacity="0.7" /> </svg> </div>
How do I add a Google One style multi-color border to a circular image?
I am creating a website for the Google DSC club at my University, and I wanted to add a Google One style border to the circular portfolio images on the site. I was wondering how to accomplish this using CSS, but pre-rendered Photoshop or Illustrator tricks would also do. I tried to modify some the code as given in this answer, but I wasn't able to achieve the perfect effect. .test { margin: 25px 0; width: 200px; height: 200px; border-radius: 50%; border: 12px solid transparent; background-size: 100% 100%, 50% 50%, 50% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat; background-image: linear-gradient(white, white), linear-gradient(30deg, #ea4335 36%, #4285f4 30%), linear-gradient(120deg, #4285f4 36%, #34a853 30%), linear-gradient(300deg, #fbbc04 36%, #ea4335 30%), linear-gradient(210deg, #34a853 36%, #fbbc04 30%); background-position: center center, left top, right top, left bottom, right bottom; background-origin: content-box, border-box, border-box, border-box, border-box; background-clip: content-box, border-box, border-box, border-box, border-box; transform: rotate(90deg); } <div class="test"></div> As you can see, the border colors are not aligned correctly. Is there any way to accomplish this using an easier method? Thank you!
SVG option To create multi-colored sectors of a circle, use stroke-dasharray Calculation of lengths of lines and spaces: For the radius R = 100px circumference = 2 * 3.1415 * 100 = 628.3 px To get the line equal to one fourth of the circle, we calculate the attributes stroke-dasharray 628.3 / 4 = 157.075 Space will be 3/4 of the circle length = 471px But since the length of the blue, red and green sectors is a little more than a quarter of a circle, we add this difference. stroke-dasharray = "183.255 445.045" stroke-dashoffset = "78.54" shifts the beginning of the sector by 1/8 of the circumference Example for one sector <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="250" height="250" viewBox="0 0 250 250" > <circle cx="125" cy="125" r="100" fill="none" stroke="#d3d3d3" stroke-width="8" /> <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="78.54" /> </svg> And also we set attributes for other color sectors. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="250" height="250" viewBox="0 0 250 250" > <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.255 425.045" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="78.54 549.76" stroke-dashoffset="340 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.255 445.045" stroke-dashoffset="525.225 " /> </svg> Add an image and cut it using a mask to fit the circles <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="40%" height="40%" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image xlink:href="https://i.stack.imgur.com/UsGg5.jpg" x="0" y="23" width="100%" height="100%" mask="url(#msk1)" /> <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </svg> The solution is adaptive and works the same in all modern browsers, including IE11,Edge UPDATE OP did not ask, but perhaps this supplement will be useful to him or someone else. SVG+CSS animation To spice up your application I add animation options. #1. Animation of rotation of the stroke around the image Wrap all the circles that form a multicolored line with the group tag <g> fill ="none" replace with fill ="transparent" for the animation to work when you hover over the whole circle .student { background: rgb(238,174,202); background: linear-gradient(90deg, rgba(238,174,202,1) 0%, rgba(148,208,233,1) 100%); } .container { display: inline-block; width:25%; } #gr1 { transform-origin:125px 125px; -webkit-transition: -webkit-transform 1s ease-in-out; transition: transform 1s ease-in-out; } #gr1:hover { -webkit-transform: rotate(720deg); transform: rotate(720deg); } <div class="student"> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/IzNqO.jpg" x="0" y="24" width="100%" height="100%" mask="url(#msk1)" /> <g id="gr1"> <circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </g> </svg> </div> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/d4AlZ.jpg" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" /> <g id="gr1"> <circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </g> </svg> </div> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/YG6VN.png" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" /> <g id="gr1"> <circle id="blue" cx="125" cy="125" r="100" fill="transparent" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </g> </svg> </div> </div> 2.# Animation of image rotation when hovering CSS rules are used to implement rotation of images #img { transform-origin:125px 125px; -webkit-transition: -webkit-transform 1s ease-in-out; transition: transform 1s ease-in-out; } #img:hover { -webkit-transform: rotate(360deg); transform: rotate(360deg); } .student { background: rgb(238,174,202); background: linear-gradient(90deg, rgba(238,174,202,1) 0%, rgba(148,208,233,1) 100%); } .container { display: inline-block; width:25%; } #img { transform-origin:125px 125px; -webkit-transition: -webkit-transform 1s ease-in-out; transition: transform 1s ease-in-out; } #img:hover { -webkit-transform: rotate(360deg); transform: rotate(360deg); } <div class="student"> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/IzNqO.jpg" x="0" y="24" width="100%" height="100%" mask="url(#msk1)" /> <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </svg> </div> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/d4AlZ.jpg" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" /> <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </svg> </div> <div class="container"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 250 250" > <defs> <mask id="msk1"> <rect width="100%" height="100%" fill="black" /> <circle cx="125" cy="125" r="100" fill="white" stroke-width="20" stroke="black" /> </mask> </defs> <image id="img" xlink:href="https://i.stack.imgur.com/YG6VN.png" x="0" y="25" width="100%" height="100%" mask="url(#msk1)" /> <circle id="blue" cx="125" cy="125" r="100" fill="none" stroke="#4285F4" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="78.54" /> <circle id="red" cx="125" cy="125" r="100" fill="none" stroke="#EA4335" stroke-width="8" stroke-dasharray="203.3 425.1" stroke-dashoffset="281.9" /> <circle id="gold" cx="125" cy="125" r="100" fill="none" stroke="#FABB04" stroke-width="8" stroke-dasharray="80 549.7" stroke-dashoffset="345 " /> <circle id="green" cx="125" cy="125" r="100" fill="none" stroke="#34A852" stroke-width="8" stroke-dasharray="183.2 445.1" stroke-dashoffset="525.2 " /> </svg> </div> </div>
tiny svg solution with masks <svg viewbox="-5 -5 10 10" height="90vh"> <defs> <mask id="mask1"> <circle r="4.5" stroke="white" fill="black" stroke-width="0.5"></circle> </mask> <mask id="mask2"> <circle r="4"fill="white"></circle> </mask> </defs> <g mask="url(#mask1)" transform="rotate(-45)"> <rect width="7" height="7" fill="#fabb04" x="-7" y="-6"></rect> <rect width="7" height="7" fill="#34a852" x="-5" y="-1"></rect> <rect width="7" height="7" fill="#ea4335" x="-2" y="-5"></rect> <rect width="7" height="7" fill="#4285f4" x="0" y="-1"></rect> </g> <image x="-4" y="-4" width="8" height="8" mask="url(#mask2)" xlink:href="https://i.stack.imgur.com/3q67w.gif"></image> </svg>
How can I rotate a symbol around its center without specifying its position twice?
I have some tile symbols that I would like to place on a grid. This is what I'm trying to achieve: Use tile coordinates to position the symbols (e.g. 4,2 instead of 85,43) Use pixel coordinates (not tile coordinates) for defining the vertices of symbols Rotate symbols around their center without specifying absolute coordinates. I have solutions to the first two (there might be better solutions though) but not the third. I can rotate the tile at 4,2 by a quarter turn with this: <!-- 10/21 = 0.47619047619 --> <use x="4" y="2" href="#rooftop-0" class="theme-0" transform="rotate(90 4.476 2.476)" /> I really don't like having to specify the tile coordinates twice. Ideally, I would like to write something like this instead: <use x="4" y="2" href="#rooftop-0" class="theme-0 rotate-1" /> Defining .rotate-1 in the stylesheet doesn't seem to have any effect on the rotation. transform-origin="50% 50%" seems to be setting the origin to 50% of the viewport or something. Maybe defining the symbol with coordinates from -10 to 10 instead of 0 to 20 would help? Should I define the viewBox of the symbols? Another solution would be manually changing the coordinates of the vertices in the symbol to create the other 3 orientations. I'd rather not! Anyway, this is what I have so far: <?xml version="1.0" standalone="no"?> <!-- 21*10+1 = 211 --> <svg width="211" height="211" version="2.0" xmlns="http://www.w3.org/2000/svg"> <style> .grid-line { fill: #DDD; } .grass-fill { fill: #8C8; } .tile { /* 1/21 = 0.04761904761 */ transform: scale(0.04761904761, 0.04761904761); } .theme-0 { --roof-color-0: #F44; --roof-color-1: #F66; --roof-color-2: #F88; --roof-color-3: #FAA; } .theme-1 { --roof-color-0: #44F; --roof-color-1: #66F; --roof-color-2: #88F; --roof-color-3: #AAF; } </style> <defs> <pattern id="grid" width="21" height="21" patternUnits="userSpaceOnUse"> <rect class="grid-line" x="0" y="0" width="1" height="21" /> <rect class="grid-line" x="0" y="0" width="21" height="1" /> </pattern> <symbol id="rooftop-0"> <g class="tile"> <rect class="grass-fill" width="20" height="20" /> <polygon style="fill: var(--roof-color-0)" points="3,2 17,2 18,8 2,8" /> <polygon style="fill: var(--roof-color-1)" points="2,8 18,8 17,14 3,14" /> <polygon style="fill: var(--roof-color-2)" points="8,8 11,14 11,18 8,18" /> <polygon style="fill: var(--roof-color-3)" points="8,8 8,18 5,18 5,14" /> </g> </symbol> <symbol id="rooftop-1"> <g class="tile"> <rect class="grass-fill" width="20" height="20" /> <polygon style="fill: var(--roof-color-0)" points="2,11 18,11 17,17 3,17" /> <polygon style="fill: var(--roof-color-1)" points="3,5 17,5 18,11 2,11" /> <polygon style="fill: var(--roof-color-2)" points="10,11 10,3 13,3 13,5" /> <polygon style="fill: var(--roof-color-3)" points="10,11 7,5 7,3 10,3" /> </g> </symbol> </defs> <g> <rect fill="#999" width="100%" height="100%" /> <rect fill="url(#grid)" width="100%" height="100%" /> </g> <g transform="translate(1, 1) scale(21, 21)"> <use x="3" y="2" href="#rooftop-0" class="theme-1" /> <!-- 10/21 = 0.47619047619 --> <use x="4" y="2" href="#rooftop-0" class="theme-0" transform="rotate(90 4.476 2.476)" /> <use x="5" y="2" href="#rooftop-1" class="theme-1" /> </g> </svg> Here's a screenshot: Is there a clean way of doing what I'm trying to do? Rotating a symbol around its center seems like something one would do all the time.
Instead of setting your <use> attributes using xand y coordinates, you can set them using transform="translate(x, y), this way, the origin parameters of the rotate() method will stay the same (0.5, 0.5): <svg viewBox="0 0 211 211"> <style> .grid-line { fill: #DDD; } .grass-fill { fill: #8C8; } .theme-0 { --roof-color-0: #F44; --roof-color-1: #F66; --roof-color-2: #F88; --roof-color-3: #FAA; } .theme-1 { --roof-color-0: #44F; --roof-color-1: #66F; --roof-color-2: #88F; --roof-color-3: #AAF; } </style> <defs> <pattern id="grid" x="-0.5" y="-0.5" width="20" height="20" patternUnits="userSpaceOnUse"> <rect class="grid-line" x="0" y="0" width="1" height="20" /> <rect class="grid-line" x="0" y="0" width="20" height="1" /> </pattern> <symbol id="rooftop-0" viewBox="0 0 20 20"> <g class="tile" transform="translate(0.5, 0.5) scale(0.95)"> <rect class="grass-fill" width="20" height="20" /> <polygon style="fill: var(--roof-color-0)" points="3,2 17,2 18,8 2,8" /> <polygon style="fill: var(--roof-color-1)" points="2,8 18,8 17,14 3,14" /> <polygon style="fill: var(--roof-color-2)" points="8,8 11,14 11,18 8,18" /> <polygon style="fill: var(--roof-color-3)" points="8,8 8,18 5,18 5,14" /> </g> </symbol> <symbol id="rooftop-1" viewBox="0 0 20 20"> <g class="tile"transform="translate(0.5, 0.5) scale(0.95)"> <rect class="grass-fill" width="20" height="20" /> <polygon style="fill: var(--roof-color-0)" points="2,11 18,11 17,17 3,17" /> <polygon style="fill: var(--roof-color-1)" points="3,5 17,5 18,11 2,11" /> <polygon style="fill: var(--roof-color-2)" points="10,11 10,3 13,3 13,5" /> <polygon style="fill: var(--roof-color-3)" points="10,11 7,5 7,3 10,3" /> </g> </symbol> </defs> <g> <rect fill="#999" width="100%" height="100%" /> <rect fill="url(#grid)" width="100%" height="100%" /> </g> <g transform="scale(20, 20)"> <use xlink:href="#rooftop-0" class="theme-1" width="1" height="1" transform="translate(4, 2) rotate(0,0.5,0.5)"/> <use xlink:href="#rooftop-1" class="theme-0" width="1" height="1" transform="translate(5, 2) rotate(90,0.5,0.5)"/> <use xlink:href="#rooftop-0" class="theme-1" width="1" height="1" transform="translate(6, 2) rotate(180,0.5,0.5)"/> </g> </svg>
I hope this is what you were asking: The symbol has now a wiewBox attribute: viewBox="0 0 20 20" This means that the symbol has a width of 20 units and a height of 20 units. Now you can use the symbol like this: <use xlink:href="#rooftop-0" width="20" height="20" x="63" y="21" /> As you can see I can give the symbol a width and a height in this case width="20" height="20" but you can give it any size you need. Also you can use the x and y attributes to reposition the used symbol. Now you can also rotate the use element around it's center by using transform="rotate(90,73,31)" This is rotating the element 90degs around the point {x:73,y:31} <svg viewBox="0 0 211 211"> <style> .grid-line { fill: #DDD; } .grass-fill { fill: #8C8; } .theme-0 { --roof-color-0: #F44; --roof-color-1: #F66; --roof-color-2: #F88; --roof-color-3: #FAA; } .theme-1 { --roof-color-0: #44F; --roof-color-1: #66F; --roof-color-2: #88F; --roof-color-3: #AAF; } </style> <defs> <pattern id="grid" width="21" height="21" patternUnits="userSpaceOnUse"> <rect class="grid-line" x="0" y="0" width="1" height="21" /> <rect class="grid-line" x="0" y="0" width="21" height="1" /> </pattern> <symbol id="rooftop-0" viewBox="0 0 20 20"> <g class="tile"> <rect class="grass-fill" width="20" height="20" /> <polygon style="fill: var(--roof-color-0)" points="3,2 17,2 18,8 2,8" /> <polygon style="fill: var(--roof-color-1)" points="2,8 18,8 17,14 3,14" /> <polygon style="fill: var(--roof-color-2)" points="8,8 11,14 11,18 8,18" /> <polygon style="fill: var(--roof-color-3)" points="8,8 8,18 5,18 5,14" /> </g> </symbol> </defs> <g> <rect fill="#999" width="100%" height="100%" /> <rect fill="url(#grid)" width="100%" height="100%" /> </g> <g transform="translate(1, 1)"> <use x="42" y="21" xlink:href="#rooftop-0" class="theme-1" width="20" height="20" /> <use x="63" y="21" xlink:href="#rooftop-0" class="theme-0" width="20" height="20" transform="rotate(90,73,31)" /> </g> </svg>