- Dapatkan pautan
- X
- E-mel
- Apl Lain
Apabila di 'hover' (atau tap), kiub akan bertukar-tukar warna.
HTML view ▼
Demo
HTML view ▼
<div class="labu">
<div class="labi">
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
</div></div>
<style>
.labu * {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.labu {
display: flex;
justify-content: center;
align-items: center;
min-height: 80vh;
background: #cfe2f3;
border-radius: 8px;
}
@keyframes animate {
0% {
filter: hue-rotate(0deg);
}
100% {
filter: hue-rotate(360deg);
}
}
.labi {
position: relative;
top: -80px;
transform: skewY(-20deg);
animation: animate 5s linear infinite;
}
.labi .kiub {
position: relative;
z-index: 2;
}
.labi .kiub:nth-child(2) {
z-index: 1;
translate: -60px -60px;
}
.labi .kiub:nth-child(3) {
z-index: 3;
translate: 60px 60px;
}
.labi .kiub div {
position: absolute;
display: flex;
flex-direction: column;
gap: 30px;
translate: calc(-70px * var(--x)) calc(-60px * var(--y));
}
.labi .kiub div span {
position: relative;
display: inline-block;
width: 50px;
height: 50px;
background: #dcdcdc;
z-index: calc(1 * var(--i));
transition: 1.5s;
}
.labi .kiub div span:hover {
transition: 0s;
background: #ef4149;
filter: drop-shadow(0 0 30px #ef4149);
}
.labi .kiub div span:hover:before, .labi .kiub div span:hover:after {
transition: 0s;
background: #ef4149;
}
.labi .kiub div span:before {
content: "";
position: absolute;
left: -40px;
width: 40px;
height: 100%;
background: #fff;
transform-origin: right;
transform: skewY(45deg);
transition: 1.5s;
}
.labi .kiub div span:after {
content: "";
position: absolute;
top: -40px;
left: 0px;
width: 100%;
height: 40px;
background: #f2f2f2;
transform-origin: bottom;
transform: skewX(45deg);
transition: 1.5s;
}
</style>
<div class="labi">
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
<div class="kiub">
<div style="--x:-1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:0; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
<div style="--x:1; --y:0;">
<span style="--i:3;"></span>
<span style="--i:2;"></span>
<span style="--i:1;"></span>
</div>
</div>
</div></div>
<style>
.labu * {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.labu {
display: flex;
justify-content: center;
align-items: center;
min-height: 80vh;
background: #cfe2f3;
border-radius: 8px;
}
@keyframes animate {
0% {
filter: hue-rotate(0deg);
}
100% {
filter: hue-rotate(360deg);
}
}
.labi {
position: relative;
top: -80px;
transform: skewY(-20deg);
animation: animate 5s linear infinite;
}
.labi .kiub {
position: relative;
z-index: 2;
}
.labi .kiub:nth-child(2) {
z-index: 1;
translate: -60px -60px;
}
.labi .kiub:nth-child(3) {
z-index: 3;
translate: 60px 60px;
}
.labi .kiub div {
position: absolute;
display: flex;
flex-direction: column;
gap: 30px;
translate: calc(-70px * var(--x)) calc(-60px * var(--y));
}
.labi .kiub div span {
position: relative;
display: inline-block;
width: 50px;
height: 50px;
background: #dcdcdc;
z-index: calc(1 * var(--i));
transition: 1.5s;
}
.labi .kiub div span:hover {
transition: 0s;
background: #ef4149;
filter: drop-shadow(0 0 30px #ef4149);
}
.labi .kiub div span:hover:before, .labi .kiub div span:hover:after {
transition: 0s;
background: #ef4149;
}
.labi .kiub div span:before {
content: "";
position: absolute;
left: -40px;
width: 40px;
height: 100%;
background: #fff;
transform-origin: right;
transform: skewY(45deg);
transition: 1.5s;
}
.labi .kiub div span:after {
content: "";
position: absolute;
top: -40px;
left: 0px;
width: 100%;
height: 40px;
background: #f2f2f2;
transform-origin: bottom;
transform: skewX(45deg);
transition: 1.5s;
}
</style>
CSS diolah, dipetik dari YouTube
Ulasan