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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dropdown on Click</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
        }

        nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #333;
            padding: 10px 20px;
            color: white;
        }

        .navbar-brand {
            font-size: 1.5em;
        }

        .menu {
            display: flex;
            align-items: center;
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .menu-item {
            margin: 0 10px;
            position: relative;
        }

        .menu-item a {
            color: white;
            text-decoration: none;
            padding: 8px 15px;
        }

        .menu-item a:hover {
            background-color: #444;
            border-radius: 5px;
        }

        .dropdownsk {
            display: none;
            position: absolute;
            top: 40px;
            right: 0;
            background-color: #444;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            z-index: 1000;
        }

        .dropdownsk a {
            display: block;
            padding: 10px 20px;
            white-space: nowrap;
            color: white;
            text-decoration: none;
        }

        .dropdownsk a:hover {
            background-color: #555;
        }

        .menu-item.active .dropdownsk {
            display: block;
        }

        .hamburger {
            display: none;
            cursor: pointer;
        }

        .hamburger div {
            width: 25px;
            height: 3px;
            background-color: white;
            margin: 5px 0;
        }

        @media (max-width: 768px) {
            .menu {
                display: none;
                flex-direction: column;
                background-color: #333;
                width: 100%;
                position: absolute;
                top: 60px;
                left: 0;
                padding: 10px 0;
            }

            .menu.active {
                display: flex;
            }

            .menu-item {
                margin: 10px 0;
                text-align: center;
            }

            .dropdownsk {
                position: relative;
                top: 0;
            }

            .hamburger {
                display: block;
            }
        }
    </style>
</head>

<body>
    <nav>
        <div class="navbar-brand">My Website</div>
        <div class="hamburger" onclick="toggleMenu()">
            <div></div>
            <div></div>
            <div></div>
        </div>
        <ul class="menu">
            <li class="menu-item">
                <a href="#">Home</a>
            </li>
            <li class="menu-item" onclick="toggleDropdown(this)">
                <a href="#">Profile</a>
                <div class="dropdown">
                    <a href="#">View Profile</a>
                    <a href="#">Logout</a>
                </div>
            </li>
            <li class="menu-item">
                <a href="#">About</a>
            </li>
        </ul>
    </nav>

    <script>
        // Toggle the mobile menu
        function toggleMenu() {
            const menu = document.querySelector('.menu');
            menu.classList.toggle('active');
        }

        // Toggle the dropdown on click
        function toggleDropdown(element) {
            // Close any other open dropdowns
            document.querySelectorAll('.menu-item').forEach(item => {
                if (item !== element) {
                    item.classList.remove('active');
                }
            });

            // Toggle the current dropdown
            element.classList.toggle('active');
        }

        // Close dropdowns when clicking outside
        document.addEventListener('click', function (e) {
            const isDropdown = e.target.closest('.menu-item');
            if (!isDropdown) {
                document.querySelectorAll('.menu-item').forEach(item => item.classList.remove('active'));
            }
        });
    </script>
</body>

</html>