DEV Community 👩‍💻👨‍💻

Cover image for Mirror Shine on Hover
Raghav Bhardwaj
Raghav Bhardwaj

Posted on

Mirror Shine on Hover

Today, I am going to show you how to create mirror shine effect on hover.

HTML

<div class="glass-shine-effect"></div>
Enter fullscreen mode Exit fullscreen mode

Important thing to note is :before and :hover styling.

SCSS

.glass-shine-effect {
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px 0 rgba(107, 107, 107, 0.37);
  backdrop-filter: blur(6px); // Just for effect
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  height: 125px;
  width: 125px;
  cursor: pointer;
  position: relative;
  transition: transform 200ms ease;
  overflow: hidden;
  &:before {
    content: "";
    position: absolute;
    height: 150%;
    width: 50px;
    transform: rotate(30deg);
    background-color: rgba(255, 255, 255, 0.2);
    left: -100px;
  }
  &:hover {
    transform: scale(1.1);
    &:before {
      transition: left 500ms ease;
      left: 170px;
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

CSS

.glass-shine-effect {
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px 0 rgba(107, 107, 107, 0.37);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 125px;
  width: 125px;
  cursor: pointer;
  position: relative;
  transition: transform 200ms ease;
  overflow: hidden;
}
.glass-shine-effect:before {
  content: "";
  position: absolute;
  height: 150%;
  width: 50px;
  transform: rotate(30deg);
  background-color: rgba(255, 255, 255, 0.2);
  left: -100px;
}
.glass-shine-effect:hover {
  transform: scale(1.1);
}
.glass-shine-effect:hover:before {
  transition: left 500ms ease;
  left: 170px;
}
Enter fullscreen mode Exit fullscreen mode

That's it. You can check out working demo here on codepen.

Top comments (0)

🌚 Life is too short to browse without dark mode