【问题标题】:generate smooth curve in clip-path: polygon在剪辑路径中生成平滑曲线:多边形
【发布时间】:2019-06-24 14:15:19
【问题描述】:

我有一个 div 元素,我想在其中使用剪辑路径添加内部曲线:多边形 css...

我已经完成了基本形状,但无法平滑曲线。

HTML:

<div id="clip_element">
</div>

CSS:

#clip_element {
  background-image: -webkit-linear-gradient(bottom, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);
  background-image: -o-linear-gradient(bottom, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);
  background-image: linear-gradient(to top, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);  
  -webkit-border-radius: 15px;
  -moz-border-radius: 15px;
  -webkit-clip-path: polygon(0% 0%,100% 0%,100% 70%,90% 80%,80% 90%,70% 100%,0% 100%);
  clip-path: polygon(0% 0%,100% 0%,100% 70%,90% 80%,80% 90%,70% 100%,0% 100%);
  }

如何使用 clip-path:polygon 使曲线平滑?

【问题讨论】:

    标签: css clip-path


    【解决方案1】:

    您可以通过使用伪元素:after 来实现这一点。这是使用这个的答案。希望对您有所帮助。

    #clip_element {
    width:200px;
    height:75px;
      background-image: -webkit-linear-gradient(bottom, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);
      background-image: -o-linear-gradient(bottom, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);
      background-image: linear-gradient(to top, #c0c0c0, #adadad, #9a9a9a, #888888, #767676);  
      -webkit-border-radius: 15px;
      -moz-border-radius: 15px;
      position:relative;  
      }
      div#clip_element:after {
        content: "";
        position: absolute;
        width: 60px;
        height: 60px;
        background: #fff;
        right: -10px;
        bottom: -30px;
        border-radius: 50%;
    }
    <div id="clip_element">
    </div>

    【讨论】:

    • @KumarAbhinav 但你没有像剪辑路径那样的透明度
    猜你喜欢
    • 2018-03-07
    • 2020-09-22
    • 2022-08-19
    • 2019-01-27
    • 2021-03-10
    • 1970-01-01
    • 2015-01-10
    • 2022-09-29
    • 2018-12-16
    相关资源
    最近更新 更多