I'm working on SVG here my concept is I have two images .overlap
with each other and using svg polygon I made five different triangles. my aim to achieve first overlay complete image display and when hover on triangles shapes background .box
box image needs to display.
This is my initial code before giving an overlay image.
.box {
position: relative;
background-image: url('https://picsum.photos/id/1/1000/800');
background-repeat: no-repeat;
width: 100%;
height: 600px;
background-size: cover;
}
polygon {
stroke-width: 1;
stroke: red;
fill: #ffffff;
}
polygon:hover {
fill: transparent;
}
<div class="box">
<svg viewbox="0 0 200 100">
<polygon points="0,100 100,100 0,50 "
style="stroke:#000000;"/>
<polygon points="0,50 100,100 50,00 0,0 "
style="stroke:#000000;"/>
<polygon points="100,100 50,00 150,0"
style="stroke:#000000;"/>
<polygon points="100,100 200,50 200,0 150,0"
style="stroke:#000000;"/>
<polygon points="100,100 200,100, 200,50"
style="stroke:#000000;"/>
</svg>
</div>
Now I have added overlay image need to come above the .box
image and polygons
shapes. Now, hover I want to display .box image in a current polygon shape like this
Code here
.box {
position: relative;
background-image: url('https://picsum.photos/id/1/1000/800');
background-repeat: no-repeat;
width: 100%;
height: 600px;
background-size: cover;
}
polygon {
stroke-width: 1;
stroke: red;
fill: #ffffff;
}
polygon:hover {
fill: transparent;
}
.overlay:hover polygon {
z-index: 100;
}
.overlay {
position: absolute;
background-image: url('https://picsum.photos/id/118/1000/800');
background-repeat: no-repeat;
width: 100%;
height: 600px;
background-size: cover;
z-index: 10;
}
<div class="overlay"></div>
<div class="box">
<svg viewbox="0 0 200 100">
<polygon points="0,100 100,100 0,50 "
style="stroke:#000000;"/>
<polygon points="0,50 100,100 50,00 0,0 "
style="stroke:#000000;"/>
<polygon points="100,100 50,00 150,0"
style="stroke:#000000;"/>
<polygon points="100,100 200,50 200,0 150,0"
style="stroke:#000000;"/>
<polygon points="100,100 200,100, 200,50"
style="stroke:#000000;"/>
</svg>
</div>
Can anyone help me out this on hover we need to adjust the z-indexes of the divs and polygon fill.