H.S*_*Sdq 5 html css sass reactjs
我正在尝试制作一个模态窗口以对模糊的背景做出反应。我想要实现的是模糊背景内容而不是模糊背景图像,因为没有图像只是模态窗口后面的内容。到目前为止,我遇到了这些解决方案磨砂玻璃、磨砂玻璃和玻璃效果,但它们都使用背景图像来应用模糊效果,但这不是我想要的。
反应组件:
import React from "react";
import './index.scss';
const Modal = ({ handleClose, show, children }) => {
return (
<div class="modal display-block">
<div class="modal-container">
<section class="modal-main">
<div class="row no-gutters header">
<div class="col">
<i class="fa fa-lg fa-close"></i>
</div>
</div>
<div class="row no-gutters content"></div>
</section>
</div>
</div>
);
};
export default Modal;
Run Code Online (Sandbox Code Playgroud)
css:
@import 'yelStrap/_variables.scss';
.modal {
position: fixed;
top: 0;
left: 0;
width:100%;
height: 100%;
}
.modal-container {
background: inherit;
position: absolute;
top: 50px;
right: 250px;
left: 0;
bottom: 0;
overflow: hidden;
}
.modal-container::before{
content: '';
width: 100% ;
height: 100%;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.5);
filter: blur(6px);
-webkit-filter: blur(6px);
-moz-filter: blur(6px);
-o-filter: blur(6px);
-ms-filter: blur(6px);
}
.modal-main {
position: relative;
background: white;
width: 90%;
min-height: 352px;
top: 10%;
left: 0px;
right: calc(10% / 2);
padding: 10px;
background-color: $white;
border-radius: 5px;
box-shadow: 0 0 12px 2px rgba(20, 150, 255, 0.15);
z-index: $zindex-modal;
}
.fa-close {
color: $water-disabled;
cursor: pointer;
}
.display-block {
display: block;
}
.display-none {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
当我将背景图像添加到 .modal-container::before 它起作用但背景颜色不起作用时!
任何帮助表示赞赏,谢谢。
就这样吧。只看结果。事实上,我建议将模式保留在您想要模糊的内容旁边,而不是将其保留在内容内。
body, html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
.bg-image {
filter: blur(8px);
-webkit-filter: blur(8px);
width: 100%;
height: 100%;
}
.bg-text {
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0, 0.4); /* Black w/opacity/see-through */
color: white;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="bg-image">
asdaidnasijbadkjhvbafvjhabdf vkjhabdfvk ahjbdfkv hjbfdkv s
</div>
<div class="bg-text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam sit dolores nam tempore dolore dicta quae fugiat assumenda, obcaecati, quibusdam. Officiis autem perspiciatis pariatur, beatae possimus, nulla nobis adipisci ipsum.</p>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)