In this tutorial, you will learn three CSS tricks: Glass Effect, Tilt Animation, and Shine Animation. The video will show you how to apply a glass effect, then add tilt & shine animation on hover. Watch the video below for a detailed tutorial.
<body>
<div class="glass">
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ullam a ipsum tempore temporibus possimus quidem id suscipit officia similique eius. Architecto reprehenderit harum illum itaque soluta a vitae, recusandae voluptates!</p>
</div>
</body>
body {
background-image: url('bg.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
}
.glass {
width: 200px;
padding: 1rem;
color: rgb(20, 64, 90);
text-align: center;
background: rgba(255,255,255, 0.2);
backdrop-filter: blur(5px);
border: 1px solid rgba(255,255,255, 0.2);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0, 0.1);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
overflow: hidden;
}
.glass:before {
content: '';
position: absolute;
top: -40%;
height: 340px;
width: 20px;
background: rgba(255,255,255, 0.3);
filter: blur(1px);
box-shadow: 0 0 10px rgba(255,255,255, 0.1);
transform: rotate(25deg) translateX(-200px);
}
.glass:hover {
animation: tilt linear 5s infinite;
}
.glass:hover:before {
animation: shine linear 5s infinite;
}
@keyframes tilt {
0% {
transform: translate(-50%, -50%) skewY(5deg);
}
50% {
transform: translate(-50%, -50%) skewY(-5deg);
}
100% {
transform: translate(-50%, -50%) skewY(5deg);
}
}
@keyframes shine {
0% {
transform: rotate(25deg) translate(180px, 70px);
}
50% {
transform: rotate(25deg) translate(-180px);
}
100% {
transform: rotate(25deg) translate(180px, 70px);
}
}