【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%
  );
}
相关推荐
荆州克莱10 分钟前
书生大模型全链路开源体系
spring boot·spring·spring cloud·css3·技术
小白小白从不日白28 分钟前
TS axios封装
前端·typescript
某公司摸鱼前端2 小时前
浏览器页面被禁用 F12(dev tools)
前端
快乐小土豆~~3 小时前
el-input设置后缀显示单位并阻止滚轮微调
前端·vue.js·elementui
下雪天的夏风3 小时前
解决:Vue 中 debugger 不生效
前端·javascript·vue.js
AC它真的很香3 小时前
el-table使用合计和固定列时,滚动条被覆盖区域无法拖拽问题
前端·javascript·vue.js
diygwcom3 小时前
electron多标签页模式更像客户端
前端·javascript·electron
加勒比海涛3 小时前
Element UI:初步探索 Vue.js 的高效 UI 框架
前端·vue.js·ui
柴华松3 小时前
多张GPU卡
java·服务器·前端
fruge3 小时前
【UI】element ui table(表格)expand实现点击一行展开功能
前端·vue.js·ui