【问题标题】:css filter: blur frosting glass effect not working, no blur, content is influencedCSS过滤器:模糊磨砂玻璃效果不起作用,没有模糊,内容受到影响
【发布时间】:2017-05-18 12:44:44
【问题描述】:

我想要一张前面有 div 的背景照片。 div 应具有模糊的深色背景和白色文本。

但它目前正在做的是:没有模糊的深色背景和深色文字。 请帮帮我!

#section0 {
background-color: lightgreen; /*normally the photo*/
}

.blurwrapper {
position: relative;
overflow: hidden;
}

.blur {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: black;
filter: blur(1px);
opacity: 0.2;
transform: scale(1.5);
z-index: 1;
}

h1 {
color: white;
}
.about {
color: white;
background: none;
margin: auto;
margin-top: 20px;
max-width: 800px;
font-size: 15px;
padding: 20px;
text-align: center;
letter-spacing: 2px;
color: white;
border-top: 1px solid white;
z-index: 2;
}
<div class="section active" id="section0">
    <div class="blurwrapper">
      <h1><span>...</span></h1>
      <p class="about">...</p>
      <div class="blur"></div>
    </div>
</div>

【问题讨论】:

    标签: html css background-color blur


    【解决方案1】:

    如您所见,模糊滤镜应用于当前元素。 这意味着如果您想模糊图像,您需要将模糊应用到具有background-image 集的#section0 容器。如果您有颜色而不是图像,您只会看到模糊的边框。

    有关更多信息,请查看文档。 https://developer.mozilla.org/en-US/docs/Web/CSS/filter

    使用您的代码给出更清晰的示例:http://codepen.io/ThePeach/full/egYbbe/

    【讨论】:

    • 那么我该怎么做才能达到我的目标?我不想模糊整个背景图像,只模糊文本所在的一方。
    • 那么解决方法就是将背景复制到另一个div中,并将其放置在与容器相同的位置,同时对其进行模糊处理。希望这是有道理的。
    • 但是我怎样才能让模糊的部分只在内容后面而不是在整个页面上呢?
    • 根据需要堆叠元素可能使用z-index?
    猜你喜欢
    • 2019-04-16
    • 2012-07-21
    • 2021-11-12
    • 2015-12-05
    • 1970-01-01
    • 2014-05-02
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    相关资源
    最近更新 更多