TikTok Tutorial #24 - How to create a Mouse-out Transition Hover Effect

Learn with us how to create a mouse-out transition hover effect!

If you found us on TikTok on the following post, check out this article and copy-paste the full code!

Happy coding! 😻

@creative.tim Too many hover effects? What’s that? 😆 find the link in bio #coding #programmingexercises #webdevelopment #csscoding ♬ original sound - Creative Tim

1. HTML Code

<h1>Button</h1>

2. CSS Code

h1::before {  
  transform: scaleX(0);
  transform-origin: bottom right;
}

h1:hover::before {
  transform: scaleX(1);
  transform-origin: bottom left;
}

h1::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0 0 0 0;
  background: #6290C8;
  z-index: -1;
  transition: transform .3s ease;
}

h1 {
  position: relative;
  font-size: 5rem;
}

html {
  block-size: 100%;
  inline-size: 100%;
}

body {
  min-block-size: 100%;
  min-inline-size: 100%;
  margin: 0;
  box-sizing: border-box;
  display: grid;
  place-content: center;
  font-family: system-ui, sans-serif;
  background-color: #C1E0F7;
}

@media (orientation: landscape) {
  body {
    grid-auto-flow: column;
  }
}

I hope you did find this tutorial useful!

For more web development or UI/UX design tutorials, follow us on:

Other useful resources: