Underline Effect on Menu

<!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>Underline Effect on Menu</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=Montserrat:[email protected];500&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 'Montserrat', sans-serif;
        }

        body {
            background-color: #383838;
        }

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

        ul {
            display: flex;
            list-style: none;
        }

        ul li {
            margin: 0 20px;
            position: relative;
        }

        ul li::before {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            background-color: #fff;
            left: 50%;
            bottom: -10px;
            transition: 0.3s all ease-in-out;
        }

        ul li:hover::before {
            width: 100%;
            left: 0;
        }

        ul li a {
            text-decoration: none;
            color: #fff;
            font-weight: 500;
            font-size: 18px;
        }
    </style>
</head>
<body>
    <section>
        <ul>
            <li><a href="">Home</a></li>
            <li><a href="">About Us</a></li>
            <li><a href="">Services</a></li>
            <li><a href="">Contact Us</a></li>
        </ul>
    </section>
</body>
</html>
                                Copy Code
                            

Result Screenshot(s)

Underline Effect on MenuWorking Sample0