CSS 不规则形状

333 阅读1分钟

效果:

代码:

<view class="title">
  <view>咔咔咔咔咔咔</view>
</view>
.title{
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: -10rpx;
}
.title > view{
  font-family: PingFangSC-Medium;
  font-weight: 500;
  font-size: 32rpx;
  color: #905C30;
  line-height: 64rpx;
  text-align: center;
  padding: 0 52rpx;
  height: 64rpx;
  background-image: linear-gradient(-23deg, #F0C564 0%, #F9DB85 100%);
  position: relative;
}
.title > view::before{
  content: "";
  width: 0;
  height: 0;
  border-top: 32rpx solid transparent;
  border-left: 12rpx solid #FFFFFF;
  border-bottom: 32rpx solid transparent;
  position: absolute;
  left: 0;
  top: 0;
}
.title > view::after{
  content: "";
  width: 0;
  height: 0;
  border-top: 32rpx solid transparent;
  border-right: 12rpx solid #FFFFFF;
  border-bottom: 32rpx solid transparent;
  position: absolute;
  right: 0;
  top: 0;
}