i am recomposing this question and i apologize for the messy first try. i made a clean html and css example to show the problem:
<!DOCTYPE html>
<html>
<div id="test">test</div>
<svg width="1" height="0.67" viewBox="0 0 1 0.67" fill="none" xmlns="http://www.w3.org/2000/svg">
<clipPath id="mypath" clipPathUnits="objectBoundingBox"> <path d="M0.765561 0.669377C0.759194 0.669006 0.752816 0.66799 0.746517 0.666302L0 0.466273V0.0948509C0 0.0424662 0.0424659 0 0.094851 0H0.905149C0.957534 0 1 0.0424662 1 0.0948509V0.479892L0.838139 0.641753C0.821451 0.658442 0.799442 0.668047 0.77656 0.669377H0.765561Z" fill="#D9D9D9"/>
</clipPath>
</svg>
</html>
<style>
#test{
display: block;
background-color:rgb(0, 167, 50);
width:369px;
height:247px;
clip-path: url("#mypath");
}
</style>
this is the div without the clip-path:
https://ibb.co/zRW7KTd
this is the div with the clip-path:
https://ibb.co/ZYvt6Lt
but the svg with the clippath is made to the exact size of the div and the result is that the clipping path has the right width, but the height is compressed, distorted.
this is what the svg looks like in the first place, having the same size and aspect ratio as the div:
https://ibb.co/Jqy76gp
so why the distortion? its driving me a little crazy..
2
Answers
Here is the solution, I got it from watching a clipPath tutorial on YouTube: the problem was that the units of the path inside the svg were absolute and not relative. I had to use https://yoksel.github.io/relative-clip-path/ to convert the path units from
userSpaceOnUse
toobjectBoundingBox
(as seen on the mentioned website) - in other words, from absolute to relative. I replaced the wholed
attribute of the path with what I got from yoksel.github.io/relative-clip-path/ and now it works just fine.Something still puzzles me though: even in the original path, there were no units like px or pt or whatever, just numbers, so whats the difference between the two paths?
I have remade the SVG with the same size as the div: