RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1266253
Accepted
Alexei
Alexei
Asked:2022-04-05 16:16:11 +0000 UTC2022-04-05 16:16:11 +0000 UTC 2022-04-05 16:16:11 +0000 UTC

如何将 svg 转换为剪辑路径?

  • 772

我需要将我的 svg 文件转换为 clip-path css 属性。有一颗多角星。

在此处输入图像描述

此图像的 SVG 代码:

<svg xmlns="http://www.w3.org/2000/svg" width="143" height="146" viewBox="0 0 143 146" fill="none">
<path d="M61.0611 10.0793C62.2089 7.80603 65.2969 7.42567 66.962 9.35247L74.8594 18.4911C76.0985 19.925 78.2408 20.1439 79.7443 18.9903L89.327 11.6381C91.3475 10.088 94.2947 11.0851 94.9589 13.5436L98.1091 25.2037C98.6034 27.0332 100.439 28.16 102.294 27.773L114.117 25.3067C116.61 24.7867 118.833 26.9638 118.365 29.467L116.144 41.3393C115.795 43.2021 116.96 45.0135 118.799 45.4697L130.522 48.3778C132.994 48.9909 134.052 51.9169 132.544 53.969L125.392 63.7019C124.27 65.229 124.533 67.3663 125.992 68.5755L135.292 76.2819C137.253 77.9067 136.937 81.002 134.688 82.1966L124.021 87.8624C122.347 88.7514 121.657 90.7912 122.447 92.5138L127.483 103.492C128.544 105.807 126.917 108.458 124.372 108.559L112.303 109.036C110.409 109.11 108.903 110.649 108.867 112.543L108.641 124.62C108.593 127.166 105.976 128.848 103.639 127.835L92.559 123.028C90.8204 122.273 88.7953 123.006 87.9412 124.697L82.4975 135.479C81.3497 137.753 78.2617 138.133 76.5966 136.206L68.6992 127.067C67.4601 125.634 65.3178 125.415 63.8142 126.568L54.2315 133.92C52.2111 135.471 49.2639 134.473 48.5997 132.015L45.4495 120.355C44.9552 118.525 43.1201 117.399 41.2649 117.786L29.4412 120.252C26.9482 120.772 24.7255 118.595 25.1938 116.092L27.4147 104.219C27.7632 102.356 26.5986 100.545 24.7593 100.089L13.0364 97.1808C10.5647 96.5677 9.5067 93.6417 11.0147 91.5896L18.1669 81.8567C19.2891 80.3295 19.0258 78.1923 17.5666 76.9831L8.26632 69.2767C6.30543 67.6518 6.62176 64.5566 8.87078 63.362L19.5376 57.6962C21.2113 56.8072 21.9014 54.7673 21.1113 53.0448L16.0758 42.0663C15.0141 39.7516 16.6421 37.1001 19.1867 36.9996L31.2555 36.523C33.1491 36.4483 34.656 34.9099 34.6915 33.0151L34.918 20.939C34.9658 18.3929 37.583 16.7103 39.9192 17.7239L50.9996 22.5309C52.7382 23.2852 54.7633 22.5529 55.6174 20.8612L61.0611 10.0793Z" fill="#7A50FF"/>
</svg>

html
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    user347472
    2022-04-05T16:38:55Z2022-04-05T16:38:55Z

    如果不需要旧浏览器,那么您可以只使用不带 SVG 的路径。坐标可以简单地取自dy属性path。只有它们必须是正确的大小,而不是通过viewBox或缩放scale。

    .clipped {
      padding: 50px;
      background-color: gray;
      clip-path: path('M61.0611 10.0793C62.2089 7.80603 65.2969 7.42567 66.962 9.35247L74.8594 18.4911C76.0985 19.925 78.2408 20.1439 79.7443 18.9903L89.327 11.6381C91.3475 10.088 94.2947 11.0851 94.9589 13.5436L98.1091 25.2037C98.6034 27.0332 100.439 28.16 102.294 27.773L114.117 25.3067C116.61 24.7867 118.833 26.9638 118.365 29.467L116.144 41.3393C115.795 43.2021 116.96 45.0135 118.799 45.4697L130.522 48.3778C132.994 48.9909 134.052 51.9169 132.544 53.969L125.392 63.7019C124.27 65.229 124.533 67.3663 125.992 68.5755L135.292 76.2819C137.253 77.9067 136.937 81.002 134.688 82.1966L124.021 87.8624C122.347 88.7514 121.657 90.7912 122.447 92.5138L127.483 103.492C128.544 105.807 126.917 108.458 124.372 108.559L112.303 109.036C110.409 109.11 108.903 110.649 108.867 112.543L108.641 124.62C108.593 127.166 105.976 128.848 103.639 127.835L92.559 123.028C90.8204 122.273 88.7953 123.006 87.9412 124.697L82.4975 135.479C81.3497 137.753 78.2617 138.133 76.5966 136.206L68.6992 127.067C67.4601 125.634 65.3178 125.415 63.8142 126.568L54.2315 133.92C52.2111 135.471 49.2639 134.473 48.5997 132.015L45.4495 120.355C44.9552 118.525 43.1201 117.399 41.2649 117.786L29.4412 120.252C26.9482 120.772 24.7255 118.595 25.1938 116.092L27.4147 104.219C27.7632 102.356 26.5986 100.545 24.7593 100.089L13.0364 97.1808C10.5647 96.5677 9.5067 93.6417 11.0147 91.5896L18.1669 81.8567C19.2891 80.3295 19.0258 78.1923 17.5666 76.9831L8.26632 69.2767C6.30543 67.6518 6.62176 64.5566 8.87078 63.362L19.5376 57.6962C21.2113 56.8072 21.9014 54.7673 21.1113 53.0448L16.0758 42.0663C15.0141 39.7516 16.6421 37.1001 19.1867 36.9996L31.2555 36.523C33.1491 36.4483 34.656 34.9099 34.6915 33.0151L34.918 20.939C34.9658 18.3929 37.583 16.7103 39.9192 17.7239L50.9996 22.5309C52.7382 23.2852 54.7633 22.5529 55.6174 20.8612L61.0611 10.0793Z');
    }
    <div class="clipped">123</div>

    这适用于使用 SVG 的旧版浏览器:

    .clipped {
      padding: 50px;
      background-color: gray;
      clip-path: url(#clip-path);
    }
    <svg xmlns="http://www.w3.org/2000/svg" width="0" height="0">
      <clipPath id="clip-path">
        <path d="M61.0611 10.0793C62.2089 7.80603 65.2969 7.42567 66.962 9.35247L74.8594 18.4911C76.0985 19.925 78.2408 20.1439 79.7443 18.9903L89.327 11.6381C91.3475 10.088 94.2947 11.0851 94.9589 13.5436L98.1091 25.2037C98.6034 27.0332 100.439 28.16 102.294 27.773L114.117 25.3067C116.61 24.7867 118.833 26.9638 118.365 29.467L116.144 41.3393C115.795 43.2021 116.96 45.0135 118.799 45.4697L130.522 48.3778C132.994 48.9909 134.052 51.9169 132.544 53.969L125.392 63.7019C124.27 65.229 124.533 67.3663 125.992 68.5755L135.292 76.2819C137.253 77.9067 136.937 81.002 134.688 82.1966L124.021 87.8624C122.347 88.7514 121.657 90.7912 122.447 92.5138L127.483 103.492C128.544 105.807 126.917 108.458 124.372 108.559L112.303 109.036C110.409 109.11 108.903 110.649 108.867 112.543L108.641 124.62C108.593 127.166 105.976 128.848 103.639 127.835L92.559 123.028C90.8204 122.273 88.7953 123.006 87.9412 124.697L82.4975 135.479C81.3497 137.753 78.2617 138.133 76.5966 136.206L68.6992 127.067C67.4601 125.634 65.3178 125.415 63.8142 126.568L54.2315 133.92C52.2111 135.471 49.2639 134.473 48.5997 132.015L45.4495 120.355C44.9552 118.525 43.1201 117.399 41.2649 117.786L29.4412 120.252C26.9482 120.772 24.7255 118.595 25.1938 116.092L27.4147 104.219C27.7632 102.356 26.5986 100.545 24.7593 100.089L13.0364 97.1808C10.5647 96.5677 9.5067 93.6417 11.0147 91.5896L18.1669 81.8567C19.2891 80.3295 19.0258 78.1923 17.5666 76.9831L8.26632 69.2767C6.30543 67.6518 6.62176 64.5566 8.87078 63.362L19.5376 57.6962C21.2113 56.8072 21.9014 54.7673 21.1113 53.0448L16.0758 42.0663C15.0141 39.7516 16.6421 37.1001 19.1867 36.9996L31.2555 36.523C33.1491 36.4483 34.656 34.9099 34.6915 33.0151L34.918 20.939C34.9658 18.3929 37.583 16.7103 39.9192 17.7239L50.9996 22.5309C52.7382 23.2852 54.7633 22.5529 55.6174 20.8612L61.0611 10.0793Z" />
      </clipPath>
    </svg>
    
    
    <div class="clipped">123</div>

    • 2

相关问题

  • 具有非均匀背景的块内的渐变边框

  • 离开页脚

  • 如何将三个字段的数据收集到一封电子邮件中?

  • Html 元素刚从父元素中出来

  • 如何在css中制作这个背景?

  • 如何制作带有斜条纹的背景?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    表格填充不起作用

    • 2 个回答
  • Marko Smith

    提示 50/50,有两个,其中一个是正确的

    • 1 个回答
  • Marko Smith

    在 PyQt5 中停止进程

    • 1 个回答
  • Marko Smith

    我的脚本不工作

    • 1 个回答
  • Marko Smith

    在文本文件中写入和读取列表

    • 2 个回答
  • Marko Smith

    如何像屏幕截图中那样并排排列这些块?

    • 1 个回答
  • Marko Smith

    确定文本文件中每一行的字符数

    • 2 个回答
  • Marko Smith

    将接口对象传递给 JAVA 构造函数

    • 1 个回答
  • Marko Smith

    正确更新数据库中的数据

    • 1 个回答
  • Marko Smith

    Python解析不是css

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5