绘制不规则图形方法 clip-path 和 linear-gradient

可以通过background属性的渐变色linear-gradient进行不规则图形绘制

在这里插入图片描述

.out-rect {
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px
    height: 80px;
    padding: 5px;
    background: linear-gradient(-45deg, transparent 10px, #58a 0) top right;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

可以通过clip-path 裁剪属性剪切不规则形状

在这里插入图片描述

  <style>
    body {
      background-color: black;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    div {
      height: 100px;
      width: 150px;
      position: relative;
      border-radius: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
      background-image: linear-gradient(45deg, gold, deeppink);
      animation: hue 3s infinite linear;
    }
    div::before,
    div::after {
      content: "";
      position: absolute;
      top: -15px;
      bottom: -15px;
      left: -15px;
      right: -15px;
      border: 5px solid #24acf2;
      border-image: linear-gradient(45deg, gold, deeppink) 1;
      clip-path: inset(0px round 10px);
      animation: clippath 3s infinite linear;
    }
    div::after {
      animation: clippath 3s infinite -1.5s linear;
    }
    span {
      color: white;
      font-size: 20px;
    }
    @keyframes hue {
      0% {
        filter: hue-rotate(0deg);
      }
      100% {
        filter: hue-rotate(360deg);
      }
    }
    @keyframes clippath {
      0% {
        clip-path: inset(0 0 95% 0);
        filter: hue-rotate(0deg);
      }
      25% {
        clip-path: inset(0 95% 0 0);
      }
      50% {
        clip-path: inset(95% 0 0 0);
      }
      75% {
        clip-path: inset(0 0 0 95%);
      }
      100% {
        clip-path: inset(0 0 95% 0);
        filter: hue-rotate(360deg);
      }
    }
  </style>
    <div>
    	<span>hello world</span>
  	</div>

在这里插入图片描述

  <style>
    .four-bugle {
      width: 600px;
      height: 400px;
      background: #ED9135;
      clip-path: path('M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z')
    }
  </style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值