I cannot get past 2 levels. (Tried on Iceweasel and Chromium.)
As a test, I tried a variant of the code presented in this earlier reply. This one consists of 3 separate files, where a.svg includes b.svg, and b.svg includes c.svg. (NB: This is not a cycle.)
<!-- a.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#b58900" />
<image x="10" y="20" width="80" height="80" xlink:href="b.svg" />
</svg>
<!-- b.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#cb4b16" />
<image x="10" y="20" width="80" height="80" xlink:href="c.svg" />
</svg>
<!-- c.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#dc322f" />
</svg>
I expected to see a large dark yellow dot, a medium-sized orange dot, and a small red dot, but I see only the first two. In fact, what I see is exactly the same as what I would see if b.svg did not include c.svg.
Why is c.svg not being included?
Is there a way to get SVG recursion to work for more than 2 levels?
SVG when used as an image must be complete in a single file.
a.svg is not an image
b.svg is included as an image by a.svg and is therefore subject to the complete in a single file image rule so any images it contains must be included as data URIs.
c.svg is ignored as b.svg cannot refer to external files.
Convert c.svg to a data URI and include it inline in b.svg to get round this.
Related
I cannot get past 2 levels. (Tried on Iceweasel and Chromium.)
As a test, I tried a variant of the code presented in this earlier reply. This one consists of 3 separate files, where a.svg includes b.svg, and b.svg includes c.svg. (NB: This is not a cycle.)
<!-- a.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#b58900" />
<image x="10" y="20" width="80" height="80" xlink:href="b.svg" />
</svg>
<!-- b.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#cb4b16" />
<image x="10" y="20" width="80" height="80" xlink:href="c.svg" />
</svg>
<!-- c.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#dc322f" />
</svg>
I expected to see a large dark yellow dot, a medium-sized orange dot, and a small red dot, but I see only the first two. In fact, what I see is exactly the same as what I would see if b.svg did not include c.svg.
Why is c.svg not being included?
Is there a way to get SVG recursion to work for more than 2 levels?
SVG when used as an image must be complete in a single file.
a.svg is not an image
b.svg is included as an image by a.svg and is therefore subject to the complete in a single file image rule so any images it contains must be included as data URIs.
c.svg is ignored as b.svg cannot refer to external files.
Convert c.svg to a data URI and include it inline in b.svg to get round this.
I cannot get past 2 levels. (Tried on Iceweasel and Chromium.)
As a test, I tried a variant of the code presented in this earlier reply. This one consists of 3 separate files, where a.svg includes b.svg, and b.svg includes c.svg. (NB: This is not a cycle.)
<!-- a.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#b58900" />
<image x="10" y="20" width="80" height="80" xlink:href="b.svg" />
</svg>
<!-- b.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#cb4b16" />
<image x="10" y="20" width="80" height="80" xlink:href="c.svg" />
</svg>
<!-- c.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#dc322f" />
</svg>
I expected to see a large dark yellow dot, a medium-sized orange dot, and a small red dot, but I see only the first two. In fact, what I see is exactly the same as what I would see if b.svg did not include c.svg.
Why is c.svg not being included?
Is there a way to get SVG recursion to work for more than 2 levels?
SVG when used as an image must be complete in a single file.
a.svg is not an image
b.svg is included as an image by a.svg and is therefore subject to the complete in a single file image rule so any images it contains must be included as data URIs.
c.svg is ignored as b.svg cannot refer to external files.
Convert c.svg to a data URI and include it inline in b.svg to get round this.
I cannot get past 2 levels. (Tried on Iceweasel and Chromium.)
As a test, I tried a variant of the code presented in this earlier reply. This one consists of 3 separate files, where a.svg includes b.svg, and b.svg includes c.svg. (NB: This is not a cycle.)
<!-- a.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#b58900" />
<image x="10" y="20" width="80" height="80" xlink:href="b.svg" />
</svg>
<!-- b.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#cb4b16" />
<image x="10" y="20" width="80" height="80" xlink:href="c.svg" />
</svg>
<!-- c.svg -->
<svg width="100%" height="100%" viewBox="-100 -100 200 200" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="-50" cy="-50" r="30" style="fill:#dc322f" />
</svg>
I expected to see a large dark yellow dot, a medium-sized orange dot, and a small red dot, but I see only the first two. In fact, what I see is exactly the same as what I would see if b.svg did not include c.svg.
Why is c.svg not being included?
Is there a way to get SVG recursion to work for more than 2 levels?
SVG when used as an image must be complete in a single file.
a.svg is not an image
b.svg is included as an image by a.svg and is therefore subject to the complete in a single file image rule so any images it contains must be included as data URIs.
c.svg is ignored as b.svg cannot refer to external files.
Convert c.svg to a data URI and include it inline in b.svg to get round this.
I'm trying to embed a set of SVG images in a blank web page.
<html><head></head>
<body>
<img width="117px" src="img/icone/phone_hex034F84.svg" alt="image">
<img width="320px" src="img/illustrazioni/SHIPPER3.svg" alt="image">
</body>
</html>
Both files are self-contained svg generated by Illustrator.
While the first does render in the browser the second (SHIPPER3.svg) doesn't.
See the code: http://104.155.112.173/land/img/illustrazioni/SHIPPER3.svg
You can download the full source from the previous link as I cannot embed it in the question (too large). Although, I'll embed here just the preamble.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 20.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="_x5B_SHIPPER1_x5D_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 733.3 587.8" style="enable-background:new 0 0 733.3 587.8;" xml:space="preserve">
<style type="text/css">
.st0{clip-path:url(#SVGID_2_);}
.st1{fill:#EDEDED;}
.st2{fill:#F2F2F2;}
If I copy and paste SHIPPER3.svg in http://www.freecodeformat.com/svg-editor.php it does render. I can also open it in Sketch with no problems.
I tried to embed SHIPPER3.svg also as inline svg but same, again, no show.
What I am missing?
Several problems in your SHIPPER3.svg:
all your top-level groups has class st0 which is said to be clipped out by clipPath that is outside entire viewBox
clipPath #SVGID_2_ has style="display:none;" what also hides it
See:
<svg version="1.1" viewBox="0 0 733.3 587.8">
<style type="text/css">
.st0{clip-path:url(#SVGID_2_);}
/* ... */
</style>
<defs>
<ellipse id="SVGID_1_" cx="1085.6" cy="279.3" rx="251.8" ry="233.4"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" style="display:none;overflow:visible;"/>
</clipPath>
<g class="st0">
<!-- ... -->
</g>
</svg>
Further to a comment I left above, you may wish to replace the <clippath id='SVGID_2_' element with the following:
<clipPath xmlns="http://www.w3.org/2000/svg" id="SVGID_2_">
<ellipse xmlns="http://www.w3.org/2000/svg" id="SVGID_1_" cx="360" cy="290" rx="325" ry="260"/>
</clipPath>
This does 2 things. (0) it removes the link to the SVGID_1_ element by inserting the data that was inside it directly. (1) repositions and sizes the ellipse
Let's start with the end-result I'm trying to achieve:
Where the length and height of the parallelogram can change independently of each other, but where the angle of the sides do not change.
With that out of the way, let's talk about why and what I've already done.
I'm fairly inexperienced with SVG, but I already know that CSS isn't enough to do what I want to do, which is to make responsive buttons that look like the above image - except that sometimes the left or right side is straight.
Initially, for those, I designed a massively wide SVG that could be used as a background and then scaled up and aligned to the left or right (as a background) so that the excess gets cut off but so that the aspect ratio does not change. For some reason that I haven't spent any time debugging, that does not work as designed.
Then, I learned a little bit more about SVG and learned about preserveAspectRatio. I used this nifty feature to make SVGs that themselves were responsive:
<?xml version="1.0" encoding="utf-8"?>
<svg id="main-box" viewBox="0 0 200 50" preserveAspectRatio="xMinYMin slice" xmlns="http://www.w3.org/2000/svg">
<rect x="22" height="50" width="178" style="fill:green;">
</rect>
<svg id="left-corner" viewBox="0 0 27 50" preserveAspectRatio="xMinYMin meet">
<polygon points="22,0 27,0 27,50 0,50" style="fill:green;"/>
</svg>
</svg>
and
<?xml version="1.0" encoding="utf-8"?>
<svg id="main-box" viewBox="0 0 200 50" preserveAspectRatio="xMaxYMin slice" xmlns="http://www.w3.org/2000/svg">
<rect height="50" width="178" style="fill:green;">
</rect>
<svg id="right-corner" viewBox="0 0 27 50" preserveAspectRatio="xMaxYMin meet">
<polygon points="0,0 27,0 5,50 0,50" style="fill:green;"/>
</svg>
</svg>
These two very easily maintain the aspect ratio of the triangle making up the side (meet) while forcing the rectangle to expand to fill the remaining space. Perfect! It does this using xMaxYMin when the triangle is on the right and xMinYMin when the triangle is on the left.
However, and fairly obviously, this approach doesn't work when you want one on the left AND one on the right!
My first attempt was a fairly silly trial of xMidYMin, which put the viewport on the center of the rectangle, but as the height expanded the edges went further outward and the triangles never showed themselves - instead rendering one gigantic rectangle!
My next attempt was very close, by removing the rectangle I achieve nearly my desired effect!
<?xml version="1.0" encoding="utf-8"?>
<svg id="main-box" viewBox="0 0 50 50" preserveAspectRatio="xMinYMin slice" xmlns="http://www.w3.org/2000/svg">
<svg id="left-corner" viewBox="0 0 27 50" preserveAspectRatio="xMinYMin meet">
<polygon points="22,0 27,0 27,50 0,50" style="fill:green;"/>
</svg>
<svg id="right-corner" viewBox="0 0 27 50" preserveAspectRatio="xMaxYMin meet">
<polygon points="0,0 27,0 5,50 0,50" style="fill:green;"/>
</svg>
</svg>
The problem here though, is that while it does expand up and down, the longer it gets the more it indents from the end!
I've also tried embedding both the start and end cuts as separate SVG into one SVG with a width of 50% (one on each side) but the embedded SVGs are stretched instead of resized when preserveAspectRatio is off for the main image, and it doesn't expand to fill space the way I need it when it's on.
<?xml version="1.0" encoding="utf-8"?>
<svg id="main-box" viewBox="0 0 200 50" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none">
<svg id="start-cut" viewBox="0 0 200 50" width="50%" height="100%" preserveAspectRatio="xMinYMin slice" xmlns="http://www.w3.org/2000/svg">
<rect x="22" height="50" width="178" style="fill:green;">
</rect>
<svg id="left-corner" viewBox="0 0 27 50" preserveAspectRatio="xMinYMin meet">
<polygon points="22,0 27,0 27,50 0,50" style="fill:green;"/>
</svg>
</svg>
<svg id="end-cut" viewBox="0 0 200 50" width="50%" x="50%" preserveAspectRatio="xMaxYMin slice" xmlns="http://www.w3.org/2000/svg">
<rect height="50" width="178" style="fill:green;">
</rect>
<svg id="right-corner" viewBox="0 0 27 50" preserveAspectRatio="xMaxYMin meet">
<polygon points="0,0 27,0 5,50 0,50" style="fill:green;"/>
</svg>
</svg>
</svg>
What can I do to keep both the left and right corners in their proper place, with their proper angle (so they must keep their aspect ratio) while the middle expands (does not need to keep it's aspect ratio)?
Here's code for a responsive SVG parallelogram:
<svg id="main-box" viewBox="0 0 2000 500" preserveAspectRatio="none"
xmlns="http://www.w3.org/2000/svg">
<style>
rect {
fill:black;
}
</style>
<rect x="190" y="0" width="90%" height="100%" transform="skewX(-20)" />
</svg>
Note the use of the skewX transform and the rect and width values to give the SVG its shape. It works fine. However, the only issue I had was when trying to use this as a background image on the body tag. There was an issue with incorrect sizing in Firefox. Researching the issue, it seems to be caused by different interpretations of the spec, rather than an unintentional bug.
You can see the use of this parallelogram on a side project I created: https://thisisa.lockdownchemz.link/
I'm not sure I understand what you want to achieve. Is it something like this :
<svg id="main-box" viewBox="0 0 100 40" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 73,0 100,40 27,40" />
</svg>