html - 模糊除 div 之外的整个页面
问题描述
我有以下代码。
除了中心的红色 div 之外,我需要将其全部模糊。
我尝试使用filter:none
orfilter:blur(0)
但这不起作用。如何模糊除红色 div 之外的背景中的所有内容?
编辑:我也尝试将它与 z-index 一起使用,但这也不起作用。
.container{
width:100%;
height:100%;
min-height:400px;
position:relative;
filter: blur(0.5rem);
z-index:1;
}
.text{
width:50%;
}
.center{
width:200px;
height:200px;
position:absolute;
top: 50%;
left:50%;
transform:translate(-50%, -50%);
background:#f00;
z-index:10;
filter: blur(0);
filter: none;
}
<div class="container">
<div class="title">
<h1>
some text
</h1>
</div>
<div class="text">
<p>
some text goes here that is blurred. some text goes here that is blurred. some text goes here that is blurred. some text goes here that is blurred...
</p>
</div>
<div class="center"></div>
</div>
解决方案
你不应该使用这个。
如果你使用.container div:not(.center)
你的问题应该得到解决。
.container div:not(.center){
width:100%;
height:100%;
min-height:400px;
position:relative;
filter: blur(0.5rem);
z-index:1;
}
.text{
width:50%;
}
.center{
width:200px;
height:200px;
position:absolute;
top: 50%;
left:50%;
transform:translate(-50%, -50%);
background:#f00;
z-index:10;
filter: blur(0);
filter: none;
}
<div class="container">
<div class="title">
<h1>
some text
</h1>
</div>
<div class="text">
<p>
some text goes here that is blurred. some text goes here that is blurred. some text goes here that is blurred. some text goes here that is blurred...
</p>
</div>
<div class="center"></div>
</div>
推荐阅读
- node.js - 如何使用 Handlebars 中当前上下文的 @key 从其他数组中获取元素?
- cloudera - 从哪里或如何下载 Cloudera 快速启动 VM 5.12
- python - 在 python 中,将某些函数映射到另一个以它们的名称作为参数的函数
- java - 获取 JRaw 的空访问令牌
- ruby-on-rails - 如何在rails中为多个表单添加共享输入字段
- python - 哪个 Python 模块可以在 while 循环中监视 3 个键组合?
- list - Unity:如何不使用 GetComponent() 将引用添加到列表中?
- python - 将散点图分配到特定的 bin
- azure - 我们如何仅为匹配模式的标签触发构建
- stream - jq --stream 在后台运行吗?