javascript - iframe 或 div 上的透明三 Angular 形

标签 javascript html css

我有一个问题。我需要在我的页面中包含一个带有 map 的 iframe。 我需要在这个 iframe 上放置一个(或两个)具有透明背景的三 Angular 形。 enter image description here 我试过这个solution ,但没有成功。 我怎样才能实现它?

最佳答案

您想要实现的目标是通过将图像裁剪为箭头形状并为其指定负边距,以便下面的元素与标题图像重叠。

概念证明:

.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>

考虑到第二个元素是 map ,我假设您希望重叠区域上的点击转到 map ,而不是标题,因此我将 pointer-events:none 添加到标题,恢复其直接子级的属性,以便它们响应指针操作。

关于javascript - iframe 或 div 上的透明三 Angular 形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47613013/

相关文章:

html - 使用负边距使 block 级元素位于其内容区域之外

javascript - 当信息窗口打开时,marker.setPosition() 会将标记带入 View - 如何阻止此操作?

javascript - 在reactjs中呈现未排序列表的问题

html - 浏览器缩小时带边框的子 div 下推

html - Bootstrap 导航栏不能很好地调整宽度

javascript - 在 IE9 中滚动是跳跃的

html - 我网站上的 header 在 IE7/IE8 中出现问题

javascript - jquery获取每张图片的宽度

javascript - jQuery UI 自动完成功能不适用于 ajax 加载的表单

javascript - 嵌套 Firebase 查询