【问题标题】:Rounded image shape using clip-path使用剪辑路径的圆形图像形状
【发布时间】:2021-03-14 09:55:33
【问题描述】:

我想要如下图所示的 css 剪辑路径

谁能帮帮我

img {
  clip-path: polygon(53% 0%, 100% 1%, 100% 50%, 100% 100%, 55% 100%, 42% 65%, 0% 52%, 44% 36%);
  border-radius:0 100% 100% 0
}
<img src="http://lorempixel.com/400/400/">

【问题讨论】:

    标签: css css-shapes clip-path


    【解决方案1】:

    mask 可以轻松做到这一点。 clip-path 的曲线会很棘手

    img {
      width:50%;
      border-radius:50%;
      -webkit-mask:
        radial-gradient(circle at top    left,transparent 45%,#fff 45.5%) top,
        radial-gradient(circle at bottom left,transparent 45%,#fff 45.5%) bottom;
      -webkit-mask-size:100% 50%;
      -webkit-mask-repeat:no-repeat;
      
    }
    <img src="https://picsum.photos/id/1012/800/800">

    另一种语法:

    img {
      width:50%;
      border-radius:50%;
      -webkit-mask:
        radial-gradient(51% 51% at 0 0   ,transparent 99%,#fff),
        radial-gradient(51% 51% at 0 100%,transparent 99%,#fff);
      -webkit-mask-composite: destination-in;
      mask-composite:intersect;
    }
    <img src="https://picsum.photos/id/1012/800/800">

    【讨论】:

    • 嗨 Temani Afif 非常感谢这正是我想要的
    • 但是,如果我使用不同的图像分辨率,形状会被拉伸。请使用下图查看digital-photo-secrets.com/images/…
    • @SureshR 因为你需要一个正方形所以一个正方形图像或者你不能有你展示的东西
    • 很抱歉给您带来更多麻烦@Temani Afif。为什么形状的左侧有边框。有什么办法可以控制吗?
    • @SureshR 你能给我截图吗,我看不到那个边框
    猜你喜欢
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 2020-09-22
    • 1970-01-01
    • 2021-03-10
    • 1970-01-01
    • 2019-01-27
    • 2016-06-28
    相关资源
    最近更新 更多