I am trying to accomplish this border in the middle but I don’t know how to go about it.
Tried using drop-shadow but it’s not perfect. Could there be an alternative to clipPath that would allow me to do this?
.hero {
position: relative;
overflow: hidden;
height: 300px !important;
width: 500px;
}
.hero-side {
position: absolute;
top: 0;
height: 100%;
}
.hero-side img {
height: 100%;
}
.hero-left {
left: 0;
z-index: 1;
background-color: #f0f;
}
.hero-right {
right: -10%;
z-index: 2;
filter:
drop-shadow(-5px 0px 0px rgba(235, 207, 82, 1))
drop-shadow(5px 5px 0px rgba(235, 207, 82, 1))
;
}
.hero-right img {
left: 10px;
clip-path: url(#separator);
}
#separator {
transform: translateY(-200px);
animation: 1s moveDown forwards;
}
@keyframes moveDown {
from {
transform: translateY(-200px);
}
to {
transform: translateY(0px)
}
}
<section id="hero" class="hero">
<div class="hero-side hero-left">
<img src="https://i.ibb.co/9rgCrm2/hero-left.jpg" alt="">
</div>
<div class="hero-side hero-right">
<img src="https://i.ibb.co/zQ6ZSWW/hero-right.jpg" alt="">
<svg viewBox="0 0 1000 1000" width="0" height="0">
<defs>
<clipPath id="separator" clipPathUnits="objectBoundingBox" >
<path d="m1,0 l-1,0 l0,0.495 l0,0.01 a0.008,0.01,46,1,0,0.103,0 a-0.008,0.01,0,1,1,0.103,0 l0,0.495 l0.794,0" />
<path d="m1.206,1 l-1,0 l0,1 l1,0"></path>
</clipPath>
</defs>
</svg>
</div>
</section>
2
Answers
Unfortunately you can’t accurately replicate a stroke with drop-shadow.
To some extent you can sometimes improve the result by stacking more shadows on top of each other.
If you need a proper stroke rendering you may rebuild your header section in
<svg>
completely.This way we can easily duplicate the clip-path as a visible stroke element via
<use>
element.In the example above I’ve recalculated the path commands to match a width of 300 units. (You can do this with svg-path-editor or any vector graphic app like inkscape, Illustrator etc). So we don’t need the
clipPathUnits="objectBoundingBox"
trick to make our clip path responsiveI don’t think you can replicate a stroke with drop-shadow accurately.
I tried to add another svg element, with a shape with a stroke that looks like the shape in the clip-path, but some of the numbers are a bit hard to adjust.