【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%
  );
}
相关推荐
上官熊猫19 分钟前
nuxt3项目打包部署到服务器后配置端口号和开启https
前端·vue3·nuxt3
dal118网工任子仪2 小时前
61,【1】BUUCTF WEB BUU XSS COURSE 11
前端·数据库·xss
约定Da于配置4 小时前
uniapp封装websocket
前端·javascript·vue.js·websocket·网络协议·学习·uni-app
山楂树の4 小时前
xr-frame 模型摆放与手势控制,支持缩放旋转
前端·xr·图形渲染
LBJ辉5 小时前
1. 小众但非常实用的 CSS 属性
前端·css
milk_yan5 小时前
Docker集成onlyoffice实现预览功能
前端·笔记·docker
m0_748255027 小时前
头歌答案--爬虫实战
java·前端·爬虫
noravinsc7 小时前
python md5加密
前端·javascript·python
ac-er88888 小时前
Yii框架优化Web应用程序性能
开发语言·前端·php
cafehaus8 小时前
抛弃node和vscode,如何用记事本开发出一个完整的vue前端项目
前端·vue.js·vscode