html - 将 vue 模态掩码设置为模糊
问题描述
我正在尝试使用vue.js在我的模态后面添加一个模糊面板,但问题是其中modal-mask
嵌套了内容,因此添加一个filter: blur()
属性会模糊所有内容。
现在我只能在背景中添加黑色。
jsfiddle: https ://jsfiddle.net/EricTalv/2eed5qjo/26/
HTML
<div id="content-container">
<div id="wrapper">
<ul id="flex-container">
<li class="flex-item">
<div id="list-area"></div>
</li>
<li class="flex-item">
<div id="img-desc-container">
<div class="image-area">
<img src="http://dukes-lancaster.org/wp-content/uploads/2014/11/placeholder.jpg">
</div>
<div class="description-area"></div>
</div>
</li>
</ul>
<button class="modal-close" @click="$emit('close')">Close</button>
</div>
</div>
</div>
CSS
/* 模糊面板 */
#modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .6);
display: table;
transition: opacity .3s ease;
}
解决方案
您需要将内容移动到单独的容器中并切换模糊类
https://jsfiddle.net/2eed5qjo/27/
<div :class="{'blur-content': showModal}">
... your content ...
</div>
<!-- use the modal component, pass in the prop -->
<modal v-if="showModal" @close="showModal = false">
</modal>
然后像这样添加一个css类
.blur-content{
filter: blur(5px);
}
推荐阅读
- javascript - 你能在 gif 中隐藏 RCE 吗?
- python - 同时从多个文件夹获取信息
- python - requests.post 返回 404 错误页面的响应 - 数据参数/表单数据问题?
- angular - 从不同的父路由路由到子路由时的行为
- cross-browser - 在 Service Worker 的事件处理程序中去抖动异步工作
- apache-spark - 使用 apache spark 失败后继续写入大型数据集
- python-3.x - Raymarcher 很慢
- javascript - 如何在没有 webpack 构建配置的情况下将 React 组件提取到库中?
- c# - (UNITY / C#) 没有从派生的泛型类调用被覆盖的函数
- c++ - 孩子如何通过成员方法访问另一个孩子的受保护成员