Animated Hover Effect On Button (Fill effect on Button) || HTML and CSS only || Free Source Code

Hello friends, in this article you will know how to create an amazing clean looking yet simple hover effect on button in under 3 minutes only by using HTML and CSS without involvement of a single line of JavaScript. This is the blog version of the tutorial uploaded on YouTube. If you want to see the full coding, you can even watch the tutorial. You can get the source code in this blog at the end or also you can download code from my GitHub repository. You can even get the source code file in the GitHub link at the end of this article. Everyone who has brief understanding of web development can understand this code.

This project just contains HTML and CSS. If you follow correctly you will be able to create one for your own project.


In order to create this animation, you will need to follow these couple of steps and it will be created.

Step 1:

First of all ,you will need to create an index.html file and paste the following code and save the changes.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Animated Hover Button - ramCoder</title>
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
    <div class="content">
      <button>Hover Me</button>
    </div>
  </body>
</html>{codeBox}

Step 2:

After completing with index.html ,you will need to create an style.css file and paste the following code and save the changes to take effect.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.content {
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgb(34, 32, 32);
}
.content button {
  background-color: tomato;
  color: white;
  font-size: 1.5rem;
  width: 200px;
  height: 60px;
  outline: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 0 rgb(226, 226, 2);
  transition: box-shadow 0.3s ease;
}
.content button:hover {
  box-shadow: inset 200px 0 0 0 rgb(226, 226, 2);
  color: black;
}{codeBox}

So, congratulations. You just created an awesome hover effect on the button to use in your next project.

Post a Comment

Previous Post Next Post