DEV Community

Cover image for Creative Button Animation Hover Effect
Stackfindover
Stackfindover

Posted on

3

Creative Button Animation Hover Effect

Hello guys, In this video you will learn how to create creative button animation hover effect using html and css.

Step:#1

Add below code inside index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>Awesome Button Css</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <link rel="stylesheet" href="style.css" />
  <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&display=swap" rel="stylesheet">
</head>

<body>
  <div class="button-outer">
    <button class="button">Hover Me</button>
  </div>
</body>

</html>
Enter fullscreen mode Exit fullscreen mode

Step:#2

Then we need to add code for style.css which code I provide in the below screen.

* {
  padding: 0;
  margin: 0;
  font-family: 'IBM Plex Sans', sans-serif;
}

html,
body {
  height: 100%;
  background: #000;
}

.button-outer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.button {
  height: 50px;
  padding: 0 30px;
  font-size: 18px;
  border: 5px solid #fff;
  cursor: pointer;
  background: #4b00ff;
  color: #fff;
  border-radius: 50px;
  position: relative;
  overflow: hidden;
  transition: left 0.5s ease-in-out;
}

.button:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: -200px;
  top: 0;
  background: linear-gradient(45deg, #f90, transparent);
  transition: left 0.5s ease-in-out;
}

.button:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  right: -200px;
  top: 0;
  background: linear-gradient(45deg, transparent, #f90);
  transition: right 0.5s ease-in-out;
}

.button:hover:after {
  right: 0;
  animation: infinite-spinning 10s 0.5s infinite;
}

.button:hover:before {
  left: 0;
  animation: infinite-spinning 10s 0.5s infinite;
}

@keyframes infinite-spinning {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}
Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
dacreb profile image
Alesba

It is an interesting solution, a good contribution

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay