Applying backdrop-filter
on the element you want to blur won't blur it. It will make elements behind it blurry. To make the element itself blurry, just use filter
.
I changed the @-webkit-keyframes
to just @keyframes
as it is compatible with Chrome. You may implement both.
Using backdrop-filter
What you need for this effect is a designated blur-overlay
that will always be on top of the first positioned ancestor (in this case, it would be the clip-container
as it has position: absolute;
).
setTimeout(() => {
addBlurOverlay();
}, 5000);
function addBlurOverlay() {
const clip = document.querySelector(".blur-overlay");
clip.classList.add("focused");
}
.focused {
background-color: rgba(0, 0, 0, .5);
animation: focusedShow 0.25s ease-in-out;
animation-fill-mode: forwards;
}
@keyframes focusedShow {
from {
backdrop-filter: blur(0);
}
to {
backdrop-filter: blur(100px);
}
}
video {
position: absolute;
top: 0;
left: 0;
max-width: 100%;
max-height: 100%;
width: 100%;
height: 100%;
object-fit: contain;
}
.blur-overlay {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 9;
background: none;
}
.clip-container {
position: absolute;
top: 0;
left: 0;
max-width: 100%;
max-height: 100%;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #0b0e12;
}
<div class="clip-container">
<div class="container">
<div class="content">
<div class="blur-overlay"></div>
<video id="clip" autoplay="true" loop>
<source src="http://optus-sport-prod-design.s3.amazonaws.com/saleshero/video/WWC_BANNER_720p_v2.mp4" type="video/mp4" type="video/mp4">
</video>
</div>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…