HTML Layouts

Preview Source code Open standalone

Set width: full 320 768 1024 1920 custom

Source code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple Hamburger Menu</title>
    <meta name="description" content="A simple responsive hamgurger menu">
    <style>
        *, *::before, *::after {
            box-sizing: border-box;
        }
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
        }
        header {
            background: #444;
            color: #fff;
            display: flex;
            align-items: center;
            padding: 1em;
        }
        header h1 {
            font-size: 1.8em;
            margin: 0 2rem 0 0;
        }
        input[type="checkbox"] {
            display: none;
        }
        label {
            cursor: pointer;
            display: block;
            text-align: center;
            font-size: 24px;
            margin-left: auto;
        }
        nav {
            display: none;
            position: absolute;
            right: 0;
            top: 4em;
            background: #444;
        }
        nav ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
        }
        nav ul li a {
            color: #fff;
            display: block;
            font-size: 1.4em;
            padding: 1rem 2rem;
            text-align: center;
            text-decoration: none;
        }
        nav ul li a:hover {
            background: #777;
        }
        #menu-toggle:checked + label + nav {
            display: block;
        }
        @media (min-width: 768px) {
            nav {
                position: static;
                display: block;
            }
            nav ul {
                flex-direction: row;
            }
            nav ul li a {
                font-size: 1.1em;
            }
            label {
                display: none;
            }
        }

    </style>
</head>
<body>
    <header>
        <h1>LOGO</h1>
        <input type="checkbox" id="menu-toggle">
        <label for="menu-toggle">☰</label>
        <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Services</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </nav>
    </header>
</body>
</html>