Create Animated Button Border With
Hover Animation HTML & CSS
Video Tutorial of Animated Button Border With Hover Animation
Animated Button Border With Hover Animation [Source Codes]
To Create Animated Button Border With Hover Animation with HTML and CSS, follow the given steps line by line:
Create a folder. You can name this folder whatever you want, and inside this folder, create the mentioned files.
Create an index.html file. The file name must be index and its extension .html
Create a style.css file. The file name must be style and its extension .css
Once you create these files, paste the given codes into the specified files. If you don’t want to do these then scroll down and download the source code by clicking download button.
First, paste the following codes into your index.html file
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title> Animated Button</title>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <div class="btn">
- <a href="#"><span>Hover Me</span></a>
- </div>
- <div class="btn round">
- <a href="#"><span>Hover Me</span></a>
- </div>
- </body>
- </html>
Now paste the following codes into your style.css file
- *{
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: 'Open Sans', 'Open Sans Regular', sans-serif;
- }
- html,body{
- display: grid;
- height: 100vh;
- place-items: center;
- background: #282A35;
- }
- .btn a{
- position: relative;
- color: #f5f5f5;
- height: 70px;
- width: 220px;
- display: block;
- text-align: center;
- border-radius: 10px;
- text-decoration: none;
- background-image: linear-gradient(115deg,#4fcf70,#fad648,#a767e5,#12bcfe,#44ce7b);
- }
- .btn a:hover{
- animation: rotate 0.4s linear infinite;
- }
- .round a{
- height: 150px;
- width: 150px;
- display: block;
- border-radius: 50%;
- }
-
- @keyframes rotate {
- 100%{
- filter: hue-rotate(-360deg)
- }
- }
- .btn a span{
- height: 86%;
- width: 95%;
- background: #111;
- display: block;
- position: absolute;
- top: 50%;
- left: 50%;
- border-radius: 6px;
- line-height: 62px;
- font-size: 25px;
- transform: translate(-50%, -50%);
- }
- .round a span {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 130px;
- width: 130px;
- border-radius: 50%;
- font-size: 20px;
- }
-
If you face any difficulties while creating your Animated Button Border With Hover Animation or your code is not working as expected, you can download the source code files by clicking on the download button.