【发布时间】:2019-06-17 17:51:07
【问题描述】:
我创建了一个带有 css clip-path 属性的三角形,里面的内容很少。
.triangle {
background-color: grey;
-webkit-clip-path: polygon(50% 10%, 0% 100%, 100% 100%);
clip-path: polygon(50% 10%, 0% 100%, 100% 100%);
height: 100%;
width: 100%;
overflow: hidden;
position: relative;
filter: drop-shadow(9px 9px 9px rgba(255, 23, 23, 0.5));
img {
width: 100%;
position: relative;
left: 0;
top: 5%;
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
width: 110%;
}
}
&::after {
background-color: black;
content: "";
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
transition: opacity .5s;
opacity: 0;
}
}
我在里面放了一些内容,为了悬停边框效果,我创建了另一个隐藏在这个三角形后面的三角形。
我已尝试::before 但无法正常工作,并且所有其他可用的解决方案都无法使用剪辑路径三角形。
【问题讨论】:
-
分享包括 HTML 在内的完整代码
-
我尝试添加代码 sn-p 但它不起作用&代码不整洁并且写得更少。
-
仍然感谢您的理解并提供替代解决方案:)