Button Hover animation with html css

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>button hover animation</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
        }
        
        .button {
            display: inline-block;
            padding: 10px 20px;
            font-size: 18px;
            color: #fff;
            text-decoration: none;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            background-color: #4caf50;
            transition: background-color 0.3s, transform 0.3s;
        }
        
        .button:before {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            width: 300%;
            height: 300%;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            transition: width 0.5s, height 0.5s, top 0.5s, left 0.5s;
            transform: translate(-50%, -50%);
            z-index: 0;
        }
        
        .button:hover {
            background-color: #45a049;
        }
        
        .button:hover::before {
            width: 0;
            height: 0;
            top: 50%;
            left: 50%;
        }
        
        .button span {
            position: relative;
            z-index: 1;
        }
    </style>
</head>

<body>
    <a href="#" class="button"><span>Hover me</span></a>
</body>

</html>

Leave a Comment

Your email address will not be published. Required fields are marked *

× How can I help you?