css - 为自定义形状的图像 overflow hidden

标签 css css-animations

这是 2 个图像层:

enter image description here

拿着电话和黑洞的手。

HTML 标记:

<div class="wrapper">
  <img class="wrapper__image" src="path/to/image.png">
</div>

SCSS:

.wrapper {
  background: url("path/to/blackhole.png") no-repeat center bottom;
  width: 528px;
  height: 600px;
  overflow: hidden;

  &__image {
    margin-left: 60px;
    margin-top: 5px;
  }
}

如您所见,带有电话的手图像在底部有点圆,还有一个黑洞是圆的,所以如果我将手推到 wrapper div 之外,就会有空格在底部的手的图像上。

有没有办法 Handlebars 的图像推到黑洞下面隐藏起来,黑洞图像上没有透明 Angular :

enter image description here

如果黑洞是正方形,那就没有问题了。

我的目的是把拿着手机的手藏在一个黑洞里,就像它从洞里滑下来一样。

最佳答案

我会使用纯 CSS 创建孔,您将能够获得所需的效果。

悬停鼠标查看效果。您只需调整颜色,使其看起来像您的图像。

.hole {
  width: 300px;
  height: 300px;
  position: relative;
  z-index: 0;
  overflow: hidden;
  border-bottom-right-radius: 50% 50px;
  border-bottom-left-radius: 50% 50px;
}

.hole::before {
  content: "";
  position: absolute;
  z-index: -1;
  height: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 100%;
  background: radial-gradient(farthest-side at top right, grey, black);
}

img {
  position:absolute;
  top:0;
  left:100px;
  transition:2s all;
}
.hole:hover img {
  top:100%;
}
<div class="hole">
  <img src="https://picsum.photos/100/200?image=1069">
</div>

关于css - 为自定义形状的图像 overflow hidden ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54343346/

相关文章:

html - 将 css 应用于单个元素,类不起作用

html - 具有透明背景的微调器?

javascript - 如果使用 sessionStorage 结束,如何保持动画的状态直到 session 结束?

Html 链接改变颜色?没有解释

html - 文本不会保留在网站上的父级中,即使被证明可以在多个平台上工作

javascript - 我怎样才能让这个动画在javascript中表现得更好?

html - 如何使这个 css 动画响应?

css - 覆盖过渡属性

css - 在 Chrome 和 IE 上看起来不错...在 Firefox 上不好?

css - 是否可以使用 Angular 2 的 ViewEncapsulation.Native 为不同的 Web 组件设置不同的 "rem"?