css: 使用clip-path绘制带有弧度的按钮开关

30 阅读1分钟

image.png

<template>
<div style="width: 280px; padding: 0 12px 12px 12px; min-height: 200px" class="rightContent"></div>
</template>
<style lang="less" scoped>
.rightContent {
  position: absolute;

  &::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -18px;
    height: 107px;
    width: 22px;
    z-index: 2;
    background-color: #fff;
    clip-path: path(' M 18,0  C 12,20  4,14  0,35 L 0,72 C  4,93 12, 87 18,107 Z');
  }
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -19px;
    height: 109px;
    width: 22px;
    z-index: 1;
    background-color: #d6d6d6;
    clip-path: path(' M 19,0  C 12,20  4,14  0,36 L 0,73 C 4,94 12,89 19,109 Z');
  }
}
 </style>