Animated Close Button

<!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>Animation Close Button</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> 
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 'Poppins', sans-serif;
        }

        body {
            background-color: #292929;
        }

        section {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100vh;
        }

        .close {
            background-color: transparent;
            text-decoration: none;
            color: transparent;
            cursor: pointer;
            font-size: 18px;
            padding: 20px;
            overflow: hidden;
            position: relative;
            transition: 0.2s all ease-in-out;
        }

        .close::before,
        .close::after {
            position: absolute;
            content: '';
            background-color: #fff;
            left: 0;
            width: 100%;
            height: 2px;
            transform-origin: center left;
            transition: 0.2s all ease-in-out;
        }

        .close::before {
            top: 0;
            transform: rotate(45deg);
        }

        .close::after {
            bottom: 0;
            transform: rotate(-45deg);
        }

        .close:hover {
            background-color: #fff;
            color: #292929;
        }

        .close:hover::before,
        .close:hover::after {
            transform: rotate(0deg);
        }
    </style>
</head>
<body>
    <section>
        <a href="" class="close">Close</a>
    </section>
</body>
</html>
                                Copy Code
                            

Result Screenshot(s)

Animated Close ButtonWorking Sample0