Easiest way to convert polygon clip-path to Microsoft Edge supported “clippath” svg?

回眸只為那壹抹淺笑 提交于 2020-07-19 11:21:29

问题


For example, I have a css class with a polygon clip-path applied to it like so:

   .services-image-left {
    -webkit-clip-path: polygon(0 0, 97% 0, 83% 100%, 0% 100%);
    clip-path: polygon(0 0, 97% 0, 83% 100%, 0% 100%); }

But I understand for this to work in Edge and IE I need to use the "clippath" property with svg points. Is there an easy way to convert the above polygon to an svg shape and apply it to everything with the .services-image-left class like the above sample?


回答1:


The conversion is pretty easy. The equivalent of that CSS clip path would be:

<svg width="0" height="0">
  <clipPath id="myclippath" clipPathUnits="objectBoundingBox">
    <polygon points="0, 0, 0.97, 0, 0.83, 1.0, 0, 1.0"/>
  </clipPath>
</svg>

Then you reference it with:

.services-image-left {
  clip-path: url(#myclippath);
  ...
}


来源:https://stackoverflow.com/questions/50838485/easiest-way-to-convert-polygon-clip-path-to-microsoft-edge-supported-clippath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!