CSS中的路径裁剪样式clip-path
一.概念:
clip-path属性可以防止部分元素通过定义的剪切区域来显示,仅通过显示的特殊区域。
1.【clip-path】
值:
| [ || ] | none
: url()
: inset()
| circle() | ellipse() | polygon()
: fill-box
| stroke-box | view-box | margin-box | border-box | padding-box
| content-box
初始值: none
应用于: 所有元素
继承性:
无
注释(以上来自ttps://www.cnblogs.com/xiaohuochai/p/7509225.html)
.div1{ height:80px;width:80px; background:yellow;
clip-path:polygon(50%0,35%40%, 0%50%,30%60%, 10%100%, 50%80%, 90%100%,70%60%,100%50%, 65%40%)
}
.flag{
height: 200px; width: 300px; background: red;position:fixed;top:100px;left:618px; border-top-right-radius: 20px; border-bottom-right-radius:20px;
}
.flag{
height:200px;width:300px;background:red;position:fixed;top:100px;left:618px;border-top-right-radius:20px;border-bottom-right-radius:20px;
}
.div1-1,.div1-2,.div1-3,.div1-4{
height: 50px;
width: 50px;
background: yellow;
clip-path:polygon(
50% 0,
35% 40%,
0% 50%,
30% 60%,
10% 100%,
50% 80%,
90% 100%,
70% 60%,
100% 50%,
65% 40%
)
}
.div1-1{
position: absolute;
right: 80px;
top: 10px;
}
.div1-2{
position: absolute;
right: 100px;
top: 64px;
}
.div1-3{
position: absolute;
right: 132px;
top: 117px;
}
.div1-4{
position: absolute;
left: 45px;
top: 139px;
}
.wood{
height: 300px;
width: 2px;
background: black;
position: fixed;
left: 617px;
bottom: 59px;
}
<body>
<div class="flag">
<div class="div1"></div>
<div class="div1-1"></div>
<div class="div1-2"></div>
<div class="div1-3"></div>
<div class="div1-4"></div>
</div>
<div class="wood"></div>
</body>
设置定位和clip-path:polygon()的方法来达到效果,以下为截图