<div class="lang_switch">
<div class="lang_switch__text pl">PL</div>
<div class="lang_switch__text en">EN</div>
<div class="lang_switch__blobs"></div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="display: none">
<defs>
<filter id="goo">
<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
<feBlend in="SourceGraphic" in2="goo" />
</filter>
</defs>
</svg>
* {
font-smoothing: antialiased;
osx-font-smoothing: grayscale;
}
*,*::before,*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: flex;
font-size: 30px;
font-family: "Roboto", sans-serif;
font-weight: 700;
color: #121212;
background-color: #2d9cdb;
}
$padding: 10px;
$margin: 5px;
$width: 80px;
.lang_switch {
position: relative;
display: flex;
margin: auto;
padding: $padding;
&__text {
width: $width;
height: $width;
line-height: $width;
text-align: center;
&:first-of-type {
margin-right: $margin;
}
}
&__blobs {
position: absolute;
z-index: -1;
top: 0;
left: 0;
width: 100%;
height: 100%;
filter: url("#goo");
&::before,
&::after {
content: "";
position: absolute;
z-index: -1;
top: $padding;
left: $padding;
width: $width;
height: $width;
border-radius: 100%;
background-color: #fefefe;
transition: transform 0.2s cubic-bezier(0.51, 0.06, 0.56, 1.37);
will-change: transform;
}
&::before {
transform: scale(0.7);
transition-delay: 0.1s;
transition-duration: 0.4s;
}
}
}
.lang_switch.changed {
.lang_switch__blobs {
&::before {
transform: translateX($width + $margin) scale(0.7);
}
&::after {
transform: translateX($width + $margin);
}
}
}
// desktop
@media only screen and (min-width: 1025px) {
.lang_switch__blobs::before {
transform: scale(1);
transition-delay: 0s;
transition-duration: 0.2s;
}
.lang_switch:hover {
cursor: pointer;
}
.lang_switch:not(.changed) {
.en:hover ~ .lang_switch__blobs {
&::before {
transform: scale(0.9);
}
&::after {
transform: translateX($width + $margin) scale(0.7);
}
}
}
.lang_switch.changed {
.lang_switch__blobs::before {
transform: translateX($width + $margin);
}
.pl:hover ~ .lang_switch__blobs {
&::before {
transform: translateX($width + $margin) scale(0.9);
}
&::after {
transform: scale(0.7);
}
}
}
}
View Compiled
const lang_switch = document.querySelector('.lang_switch');
lang_switch.onclick = () => lang_switch.classList.toggle('changed')
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.