Doom Flicker

by Venkatesh Dematti

HTML

<button class="btn">
  <span class="background">
    Hello World
  </span>
</button>


<!-- Our <button> now has a new child, .background. This span houses all of the cosmetic styles (background color, font stuff, etc).

When we mouse over the plain-jane button, it causes the child to peek out above. The button, however, is stationary. -->

CSS

.background {
    will-change: transform;
    transition: transform 450ms;
  }
  
  .btn:hover .background {
    transition: transform 150ms;
    transform: translateY(-10px);
  }
  
  /* Toggle me on for a clue! */
  .btn {
    outline: auto;
  }
  
  
  .btn {
  width: 100px;
  height: 100px;
  border: none;
  background: transparent;
  padding: 0px;
}

.background {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: slateblue;
  color: white;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  .btn:hover .background {
    transition: none;
  }
}