我有一个问题。我需要在我的网页上添加一张带有地图的iframe。而且我需要在具有透明背景的iframe上放置一个(或两个)三角形。我已经尝试过这种解决方案,但是没有用。我怎么知道呢?
您想要实现的目标是通过将图像裁剪为箭头形状并给其负的页边距,从而使下面的元素与标题图像重叠。
概念证明:
.example {
-webkit-clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(50% + 20px) calc(100% - 20px), 50% 100%, calc(50% - 20px) calc(100% - 20px), 0 calc(100% - 20px));
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(50% + 20px) calc(100% - 20px), 50% 100%, calc(50% - 20px) calc(100% - 20px), 0 calc(100% - 20px));
background: #fff url(https://source.unsplash.com/random/800x120) no-repeat 50% 50% /cover;
pointer-events: none;
/* the rest is only relevant for this snippet */
height: 120px;
margin-bottom: -20px;
}
.example > * {
/* in case you place anything inside the header div */
pointer-events: all;
}
.test {
background-color: #777;
min-height: 80px;
}
<div class="example"></div>
<div class="test"></div>
考虑到第二个元素是一个地图,我假设您希望在重叠区域上单击以转到地图上,而不是标题上,因此我将其添加pointer-events:none
到标题中,还原了其直接子级的属性,以便它们响应指针操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句