I'm attempting to create a blurred text effect that transitions behind a semi-transparent container label.
I've experimented with combining the backdrop-filter and filter properties along with the filter function blur(), but I haven't been able to get it to work as desired.
This is the visual outcome I am aiming for:
https://i.sstatic.net/h5gPl.png
Here's the code snippet (the screen may be too small to display the complete result):
var page = 1;
var pages = 3;
function previous() {
document.getElementById('label-previous').classList.add('clicked');
document.getElementById('pages').classList.remove('page' + page);
if ( page == pages ) {
document.getElementById('label-next').classList.remove('hidden');
}
if ( page == 2 ) {
document.getElementById('label-previous').classList.add('hidden');
}
page--;
setTimeout(function() {
document.getElementById('label-previous').classList.remove('clicked');
}, 100);
}
function next() {
document.getElementById('label-next').classList.add('clicked');
document.getElementById('pages').classList.add('page' + (page + 1));
if ( page == 1 ) {
document.getElementById('label-previous').classList.remove('hidden');
}
if ( page + 1 == pages ) {
document.getElementById('label-next').classList.add('hidden');
}
page++;
setTimeout(function() {
document.getElementById('label-next').classList.remove('clicked');
}, 100);
}
body, html {
height: 100%;
}
body {
background-color: #222;
overflow: hidden;
margin: 0;
user-select: none;
white-space: nowrap;
}
div {
height: 100%;
margin-left: 0px;
width: 100%;
-webkit-transition: margin-left 1s linear;
}
div.page2 {
margin-left: -100%;
}
div.page3 {
margin-left: -200%;
}
input[type=checkbox] {
display: none;
}
label {
/*
backdrop-filter: blur(3px);
*/
background-color: rgba(255, 255, 255, 0.1);
color: #ccc;
/*
filter: blur(3px);
*/
font-family: consolas;
font-size: 5em;
height: 100%;
line-height: 100vh;
opacity: 1;
pointer-events: initial;
position: absolute;
text-align: center;
vertical-align: middle;
width: 200px;
-webkit-transition: background-color 0.1s linear, color 0.1s linear, opacity 0.8s 0.2s linear;
}
#label-previous {
left: 0px;
}
#label-next {
left: calc(100% - 200px);
}
label.clicked {
background-color: rgba(255, 255, 255, 0.2);
color: #fff;
}
label.hidden {
opacity: 0;
pointer-events: none;
}
span {
color: #ccc;
display: inline-block;
font-family: consolas;
font-size: 2em;
margin-left: 400px;
margin-top: 200px;
width: calc(100% - 400px);
}
<div id="pages">
<input id="previous" onchange="previous()" type="checkbox"><label class="hidden" for="previous" id="label-previous"><</label>
<span>Page 1</span><span>Page 2</span><span>Page 3</span>
<input id="next" onchange="next()" type="checkbox"><label for="next" id="label-next">></label>
</div>