You have the option to enclose the modal within a container and apply backdrop-filter
:
.todo {
position: relative;
display: grid;
}
.modal-container {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
backdrop-filter: blur(5px);
height: 100vh;
width: 100%;
}
.modal {
display: grid;
width: 500px;
height: 200px;
background: #fafafa;
box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
visibility: visible;
opacity: 1;
}
<div class='todo'>
<div class='todo__sidebar'>
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
<div class="modal-container">
<div class='modal'>
<span>12345</span>
</div>
</div>
</div>
</div>
However, keep in mind that the support for this feature is limited.
An alternative approach is to utilize JavaScript:
document.querySelector('ul').style.filter = 'blur(5px)';
.todo {
display: grid;
}
.modal {
display: grid;
position: fixed;
width: 500px;
height: 200px;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
background: #fafafa;
box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
visibility: visible;
opacity: 1;
}
<div class='todo'>
<div class='todo__sidebar'>
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
<div class='modal'>
<span>12345</span>
</div>
</div>
</div>
Alternatively, you can rearrange the elements in the HTML and utilize the sibling selector (~
):
.todo {
display: grid;
}
.modal {
display: grid;
position: fixed;
width: 500px;
height: 200px;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
background: #fafafa;
box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
visibility: visible;
opacity: 1;
z-index: 1;
}
.modal ~ ul {
filter: blur(5px);
}
<div class='todo'>
<div class='todo__sidebar'>
<div class='modal'>
<span>12345</span>
</div>
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
</div>
</div>
These solutions may not be perfect, but they provide some options if necessary.