top of page

How to increase your buttons size when the user hovers over

Writer: Web Coding
Web Coding
Dec 10, 2020
1 min read

Today I will be teaching you how to increase your buttons size when the user hovers over for your website using CSS animation


HTML

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <button>Click Me!</button>
</body>
</html>

CSS

*{
 padding: 0;
 margin: 0;
}

body{
 min-height: 100vh;
 display: flex;
 align-items: center;
 justify-content: center;
 background: black;
}

button{
 font-size: 48px;
 border-radius: 10px;
 cursor: pointer;
 border: none;
 outline: none;
 padding: 3% 0 3% 0;
 width: 40%;
 text-transform: uppercase;
 background-color: #560238;
 color: #d6d6d6;
 animation-name: scaleDown;
 animation-duration: 0.3s;
 animation-timing-function: linear;
 animation-fill-mode: linear;
 animation-fill-mode: forwards;
}

button:hover{
 animation-name: scaleUp;
 animation-duration: 0.3s;
 animation-timing-function: linear;
 animation-fill-mode: forwards;
}


@keyframes scaleDown{
    0% {transform: scale(1.1);}
    100% {transform: scale(1);}
}

@keyframes scaleUp{
    0% {transform: scale(1);}
    100% {transform: scale(1.1);}
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on


YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

 
 
 

Comments


  • YouTube
  • Instagram

©2020 by Web Coding. Proudly created with Wix.com

bottom of page