【CSS3】一些好看的clip-path(一)

html 复制代码
<div class="box">
 <div class="p1"></div>
 </div>
 <div class="box">
   <div class="p2"></div>
 </div>
 <div class="box">
   <div class="p3"></div>
 </div>
 <div class="box">
   <div class="p4"></div>
 </div>
css 复制代码
.box {
  width: 100px;
  height: 100px;
  background-color: red;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px;
  div {
    width: 74px;
    height: 74px;
    background-color: rgb(255, 255, 255);
  }
}
.p1 {
  clip-path: polygon(
    16.6% 16.6%,

    33.3% 0%,
    50% 16.6%,
    66.6% 0%,

    83.3% 16.6%,

    100% 33%,
    83.3% 50%,
    100% 66.6%,

    83.3% 83.3%,

    66.6% 100%,
    50% 83.3%,
    33.3% 100%,

    16.6% 83.3%,

    0% 66.6%,
    16.6% 50%,
    0% 33%
  );
}
.p2 {
  clip-path: polygon(
    20% 20%,

    33.3% 0%,
    50% 16.6%,
    66.6% 0%,

    80% 20%,

    100% 33%,
    83.3% 50%,
    100% 66.6%,

    80% 80%,

    66.6% 100%,
    50% 83.3%,
    33.3% 100%,

    20% 80%,

    0% 66.6%,
    16.6% 50%,
    0% 33%
  );
}
.p3 {
  clip-path: polygon(
    23.3% 23.3%,

    33.3% 0%,
    50% 16.6%,
    66.6% 0%,

    76.6% 23.3%,

    100% 33%,
    83.3% 50%,
    100% 66.6%,

    76.6% 76.6%,

    66.6% 100%,
    50% 83.3%,
    33.3% 100%,

    23.3% 76.6%,

    0% 66.6%,
    16.6% 50%,
    0% 33%
  );
}
.p4 {
  clip-path: polygon(
    26.6% 26.6%,

    33.3% 0%,
    50% 16.6%,
    66.6% 0%,

    73.3% 26.6%,

    100% 33%,
    83.3% 50%,
    100% 66.6%,

    73.3% 73.3%,

    66.6% 100%,
    50% 83.3%,
    33.3% 100%,

    26.6% 73.3%,

    0% 66.6%,
    16.6% 50%,
    0% 33%
  );
}
相关推荐
mCell21 小时前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip21 小时前
Node.js 子进程:child_process
前端·javascript
excel1 天前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel1 天前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼1 天前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping1 天前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
石金龙1 天前
[译] Composition in CSS
前端·css
白水清风1 天前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化
Ticnix1 天前
函数封装实现Echarts多表渲染/叠加渲染
前端·echarts
用户22152044278001 天前
new、原型和原型链浅析
前端·javascript