I started learn web dev some times ago and I came across an issue I've been on for months now.
Here's the thing, I got an svg path that's clipping my background div (which contain an img and an iframe). The shape is morphing every change of sections (5 sections, five time) using JS. But I want the shape to always be centered beacause on some screens depending on the dimensions, it doesn't render like it should.
The SVG :
<svg class="morph" viewBox="0 0 '+ viewportWidth +' '+ viewportHeight +'" height="'+ viewportHeight +'px" width="'+ viewportWidth +'px" preserveAspectRatio="xMidYMid meet" xml:space="peserve"><clipPath id="clipMorph"><path id="morphPath" d="M 262.9,252.2 C 210.1,338.2 212.6,487.6 288.8,553.9 372.2,626.5 511.2,517.8 620.3,536.3 750.6,558.4 860.3,723 987.3,686.5 1089,657.3 1168,534.7 1173,429.2 1178,313.7 1096,189.1 995.1,130.7 852.1,47.07 658.8,78.95 498.1,119.2 410.7,141.1 322.6,154.8 262.9,252.2 Z" /></clipPath></svg>
Background div CSS :
.background{
height:100vh;
width:100vw;
position:fixed;
z-index:0;
clip-path:url(#clipMorph);
-webkit-clip-path:url(#clipMorph);
background-image:url(../home_mobile.jpg);
background-size:cover}
I tried to :
.preserveAspectRatio but nothing append
.clipPathUnits seems to make shape and background div disappear
.getting the bounding box to manipulate the path with translate but the function always return no width or height for it
{ x: 959.5, y: 459.5, width: 0, height: 0, top: 459.5, right: 959.5, bottom: 459.5, left: 959.5 }