How to make angled SVGs interlock
up vote
0
down vote
favorite
I currently have two SVGs that were designed to interlock with eachother but the higher SVG (The first in the imgur link) acts as if it were a rectangle and "pushes" the lower SVG (The second picture in the imgur link) down away from it and they end up with a large space between them (The third imgur link). I have only changed the width of the second SVG in the code so far. Without manually aligning them, which would ruin my page's responsiveness, is there a way to give the SVG a smaller hitbox or similar?
https://imgur.com/a/YtBuso4
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1250">
<defs>
<style>
.cls-1 {
fill: #190eae;
}
</style>
</defs>
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<defs>
<style>
.cls-1 {
opacity: 0.7;
}
</style>
</defs>
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-1" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Thank you
html css svg
add a comment |
up vote
0
down vote
favorite
I currently have two SVGs that were designed to interlock with eachother but the higher SVG (The first in the imgur link) acts as if it were a rectangle and "pushes" the lower SVG (The second picture in the imgur link) down away from it and they end up with a large space between them (The third imgur link). I have only changed the width of the second SVG in the code so far. Without manually aligning them, which would ruin my page's responsiveness, is there a way to give the SVG a smaller hitbox or similar?
https://imgur.com/a/YtBuso4
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1250">
<defs>
<style>
.cls-1 {
fill: #190eae;
}
</style>
</defs>
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<defs>
<style>
.cls-1 {
opacity: 0.7;
}
</style>
</defs>
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-1" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Thank you
html css svg
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I currently have two SVGs that were designed to interlock with eachother but the higher SVG (The first in the imgur link) acts as if it were a rectangle and "pushes" the lower SVG (The second picture in the imgur link) down away from it and they end up with a large space between them (The third imgur link). I have only changed the width of the second SVG in the code so far. Without manually aligning them, which would ruin my page's responsiveness, is there a way to give the SVG a smaller hitbox or similar?
https://imgur.com/a/YtBuso4
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1250">
<defs>
<style>
.cls-1 {
fill: #190eae;
}
</style>
</defs>
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<defs>
<style>
.cls-1 {
opacity: 0.7;
}
</style>
</defs>
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-1" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Thank you
html css svg
I currently have two SVGs that were designed to interlock with eachother but the higher SVG (The first in the imgur link) acts as if it were a rectangle and "pushes" the lower SVG (The second picture in the imgur link) down away from it and they end up with a large space between them (The third imgur link). I have only changed the width of the second SVG in the code so far. Without manually aligning them, which would ruin my page's responsiveness, is there a way to give the SVG a smaller hitbox or similar?
https://imgur.com/a/YtBuso4
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1250">
<defs>
<style>
.cls-1 {
fill: #190eae;
}
</style>
</defs>
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<defs>
<style>
.cls-1 {
opacity: 0.7;
}
</style>
</defs>
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-1" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Thank you
html css svg
html css svg
edited Nov 21 at 18:52
asked Nov 21 at 18:36
Jason Wren
206
206
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58
add a comment |
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I think the most simple solution to your problem is to lessen the viewBox height of the first <svg>
, but to show the overflow. That way, the triangular form at the bottom will "slip" under the second <svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Note how I have moved the styles outside the SVGs. They are part of the same DOM anyway, and if both quote the same class name, both styles will be applied to both paths. I've changed the class name for one of them, so that does not happen.
Another issue is that <svg>
elements in HTML are inline-blocks. As such they have a line height, and if they are displayed one below the other (as happens here because their default width is 100%), that may lead to a small visible gap between their layout boxes. Setting display:block
solves that.
The trick is in the CSS propertyoverflow:visible
, applied to (at least) the first svg element.
– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I think the most simple solution to your problem is to lessen the viewBox height of the first <svg>
, but to show the overflow. That way, the triangular form at the bottom will "slip" under the second <svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Note how I have moved the styles outside the SVGs. They are part of the same DOM anyway, and if both quote the same class name, both styles will be applied to both paths. I've changed the class name for one of them, so that does not happen.
Another issue is that <svg>
elements in HTML are inline-blocks. As such they have a line height, and if they are displayed one below the other (as happens here because their default width is 100%), that may lead to a small visible gap between their layout boxes. Setting display:block
solves that.
The trick is in the CSS propertyoverflow:visible
, applied to (at least) the first svg element.
– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
|
show 1 more comment
up vote
1
down vote
accepted
I think the most simple solution to your problem is to lessen the viewBox height of the first <svg>
, but to show the overflow. That way, the triangular form at the bottom will "slip" under the second <svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Note how I have moved the styles outside the SVGs. They are part of the same DOM anyway, and if both quote the same class name, both styles will be applied to both paths. I've changed the class name for one of them, so that does not happen.
Another issue is that <svg>
elements in HTML are inline-blocks. As such they have a line height, and if they are displayed one below the other (as happens here because their default width is 100%), that may lead to a small visible gap between their layout boxes. Setting display:block
solves that.
The trick is in the CSS propertyoverflow:visible
, applied to (at least) the first svg element.
– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
|
show 1 more comment
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I think the most simple solution to your problem is to lessen the viewBox height of the first <svg>
, but to show the overflow. That way, the triangular form at the bottom will "slip" under the second <svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Note how I have moved the styles outside the SVGs. They are part of the same DOM anyway, and if both quote the same class name, both styles will be applied to both paths. I've changed the class name for one of them, so that does not happen.
Another issue is that <svg>
elements in HTML are inline-blocks. As such they have a line height, and if they are displayed one below the other (as happens here because their default width is 100%), that may lead to a small visible gap between their layout boxes. Setting display:block
solves that.
I think the most simple solution to your problem is to lessen the viewBox height of the first <svg>
, but to show the overflow. That way, the triangular form at the bottom will "slip" under the second <svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
Note how I have moved the styles outside the SVGs. They are part of the same DOM anyway, and if both quote the same class name, both styles will be applied to both paths. I've changed the class name for one of them, so that does not happen.
Another issue is that <svg>
elements in HTML are inline-blocks. As such they have a line height, and if they are displayed one below the other (as happens here because their default width is 100%), that may lead to a small visible gap between their layout boxes. Setting display:block
solves that.
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
svg {
overflow:visible;
display:block;
}
.cls-1 {
fill: #190eae;
}
.cls-2 {
opacity: 0.7;
}
<svg id="svg-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
<path id="bali-beautiful-beauty-433539" class="cls-1" d="M0,0H1920V1080L0,1250Z"/>
</svg>
<svg id="svg-bottom" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 1080.021" id="sectiona">
<g id="Group_78" data-name="Group 78" transform="translate(-488 -3248.979)">
<path id="Path_26" data-name="Path 26" class="cls-2" d="M-1-16.511l960-85.021V978.489l-960-85Z" transform="translate(489 3350.511)"/>
</g>
</svg>
edited Nov 21 at 21:51
answered Nov 21 at 21:38
ccprog
8,48311027
8,48311027
The trick is in the CSS propertyoverflow:visible
, applied to (at least) the first svg element.
– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
|
show 1 more comment
The trick is in the CSS propertyoverflow:visible
, applied to (at least) the first svg element.
– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
The trick is in the CSS property
overflow:visible
, applied to (at least) the first svg element.– ccprog
Nov 21 at 22:12
The trick is in the CSS property
overflow:visible
, applied to (at least) the first svg element.– ccprog
Nov 21 at 22:12
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
I am able to drop the top SVG by set pixel amounts but when I change this to use the view height/width it seemingly does not work, is there a way around this? Otherwise I am unable to shrink the website and have it be responsive
– Jason Wren
Nov 21 at 22:17
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
"when I change this to use the view height/width": I don't understand this. What are you doing?
– ccprog
Nov 21 at 22:23
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
When I change the viewbox's height or width I will need it to be relative to the viewport
– Jason Wren
Nov 21 at 22:30
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
I guess a better question may be: Is there a better way to have a website that is made up of alternating facing trapeziums without this method of using SVGs?
– Jason Wren
Nov 21 at 22:36
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418557%2fhow-to-make-angled-svgs-interlock%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As it stands, your question is quite unclear. Could you please edit it and include some code; ideally a Minimal, Complete, and Verifiable example?
– ccprog
Nov 21 at 18:45
Do the two SVGs need to "move" in relation to each other? If yes, in what way? If static, should there be a distance between them?
– ccprog
Nov 21 at 20:43
No, they should be touching and "slot" into eachother, but the first SVG has seemingly taken the space of a rectangle as the two "tips" of the SVGs line up
– Jason Wren
Nov 21 at 20:58