高斯模糊滤镜使受影响图像上方的文本隐藏 [英] Gaussian blur filter causes text above the affected image it to hide

查看:32
本文介绍了高斯模糊滤镜使受影响图像上方的文本隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试模糊网页上的 CSS 中的图像时遇到问题:在受影响的图像上方呈现的任何元素在该过程中及之后均会隐藏。我该如何解决该问题?

I encountered a problem while trying to blur an image in CSS on my webpage: any element rendered above the affected image will hide during and after the procedure. How can I resolve the issue?

有关该问题本身的更多信息,我发布了一个片段,其中包含具有该确切问题的示例。

For more information about the problem itself, I posted a snippet containing an example featuring that exact problem.

.placeholder {
  display: block;
  /* Align the content within the container near the center. */
  text-align: center;
  /* Calculate both the width and height of the element. */
  width: calc(100vw / 3);
  height: calc(100vw / 3 * 2 / 3);
}

.placeholder img {
  display: inline;
  /* Fill the entire parent element. */
  width: 100%;
  height: 100%;
  /* Adjust the way the image is fit into the parent. */
  object-fit: cover;
  /* Add a transition to the element whenever an effect will be applied to it. */
  transition: all 0.5s linear;
}

.placeholder > p.article {
  display: inline-block;
  /* Calculate the desired margin of the element. */
  margin: calc(-100vw / 3 * 2 / 3 - 1em) auto 0;
  /* Align the element vertically near the middle. */
  vertical-align: middle;
  /* Adjust the readability of the text. */
  color: white;
}

.placeholder:hover img {
  /* Blur the image inside the container when the cursor is above it. */
  filter: blur(4px);
}

<div class="placeholder">
  <img src="http://fennek.mobi/bilder/fennek-3.jpg">
  <p class="article">A lazy fennec.</p>
</div>
<p>Copyright © http://fennek.mobi/</p>

推荐答案

添加位置:相对 .imageLabel

body {
  margin: 0;
}
.imageFolder {
  float: left;
  display: block;
  width: calc(100vw / 3 - 0px);
  height: calc(100vw / 3 * 2 / 3 - 0px);
  border: 0px solid #444;
  overflow: hidden;
  text-align: center;
  vertical-align: middle;
}
.imageBox {
  display: inline;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.imageBox img {
  display: inline;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.2s ease-in;
}
.imageLabel {
  position: relative;
  display: inline-block;
  margin: calc(0px - 100vw / 3 * 2 / 3) auto 0;
  height: 40px;
  line-height: 40px;
  font-weight: 700;
  font-size: 24px;
  padding: 10px 40px;
  text-decoration: none;
  color: white;
  opacity: 0;
  text-align: center;
  vertical-align: middle;
  border: 1px solid white;
}
.imageFolder:hover > .imageBox img {
  width: calc(100% + 30px);
  height: calc(100% + 20px);
  margin: -10px -15px;
  transition: all 0.6s ease-out;
  filter: blur(4px);
}
.imageFolder:hover > .imageLabel {
  opacity: 1;
  transition: all 0.6s ease-out;
}

<a href="">
  <div class="imageFolder">
    <div class="imageBox">
      <img src="http://tim.nikischin.com/library/gallery/087_Charlotte/_IMG4015.jpg" alt="">
    </div>
    <div class="imageLabel">Charlotte</div>
  </div>
</a>

这篇关于高斯模糊滤镜使受影响图像上方的文本隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆