top of page
Writer's pictureWeb Coding

How to increase your buttons size when the user hovers over

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

*{
 padding0;
 margin0;
}

body{
 min-height100vh;
 displayflex;
 align-itemscenter;
 justify-contentcenter;
 backgroundblack;
}

button{
 font-size48px;
 border-radius10px;
 cursorpointer;
 bordernone;
 outlinenone;
 padding3% 0 3% 0;
 width40%;
 text-transformuppercase;
 background-color#560238;
 color#d6d6d6;
 animation-name: scaleDown;
 animation-duration0.3s;
 animation-timing-functionlinear;
 animation-fill-modelinear;
 animation-fill-modeforwards;
}

button:hover{
 animation-name: scaleUp;
 animation-duration0.3s;
 animation-timing-functionlinear;
 animation-fill-modeforwards;
}


@keyframes scaleDown{
    0% {transformscale(1.1);}
    100% {transformscale(1);}
}

@keyframes scaleUp{
    0% {transformscale(1);}
    100% {transformscale(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

4 views

Comments


bottom of page