【发布时间】:2020-06-20 20:44:20
【问题描述】:
我有clip-part做“切角”效果。
我想将背景更改为白色并使用绿色边框。问题是,当我将背景更改为白色时,角落是空的:
如何在悬停时制作绿色边框?
.test {
background: red;
width: 100px;
height: 100px;
/* CORNERS */
clip-path: polygon(10px 0%, calc(100% - 10px) 0%, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0% calc(100% - 10px), 0% 10px);
}
.test:hover {
background: white;
cursor: pointer;
border: 3px solid green;
}
<div class='test'>Test</div>
【问题讨论】:
-
对于 infos ,如果在 2 级容器上使用 clip-path,则可以使用 drop-shadow() filter 在半透明边缘周围添加阴影。子节点上的剪辑路径,然后在父节点上投影:jsfiddle.net/q9tdpvfg