Skip to content

Full-screen hamburger mobile menu in HTML and CSS

A hamburger button that morphs into a cross and opens a full-screen menu: trapped focus, Escape to close and a call button at the bottom.

Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Menu mobile hamburger plein écran</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="demo">
      <header class="mmhp" data-mmhp>
        <div class="mmhp__bar">
menu.js
document.querySelectorAll("[data-mmhp]").forEach((root) => {
  const toggle = root.querySelector("[data-mmhp-toggle]");
  const panel = root.querySelector("[data-mmhp-panel]");
  let blocked = [];

  // Everything outside the toggle and the panel becomes inert, so screen readers stay in the menu too.
  function isolate() {
    const path = new Set();
    [toggle, panel].forEach((el) => {
      for (let node = el; node && node !== document.body; node = node.parentElement) path.add(node);
    });
    path.forEach((node) => {
style.css
:root {
  --mmhp-bg: #fffaf3;
  --mmhp-text: #2a1e14;
  --mmhp-muted: #6b5747;
  --mmhp-line: #eadfd2;
  --mmhp-hover: #f5ebde;
  --mmhp-card: #ffffff;
  --mmhp-accent: #9a3412;
  --mmhp-accent-hover: #7c2d12;
  --mmhp-on-accent: #ffffff;
  --mmhp-mark: #2a1e14;
  --mmhp-on-mark: #fffaf3;

Free component: copy it freely, including for commercial projects.

Breadcrumbs and pagination components in HTML and CSS
  • A bottom bar with Call, Directions and Free quote that tucks away while visitors read down the page and returns as soon as they scroll up. Built for tradespeople whose customers arrive on a phone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A slim bar at the top of the page with a message, a link and a close button; once closed, it stays hidden for the period you choose.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A sticky sidebar table of contents for blog posts: it highlights the section being read, shows the reading time left and folds into a list under the title on mobile.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A column of dots on the side of the page that follows the section being read and lets visitors jump to it, with a label on hover and focus.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An order step indicator: finished steps clickable to go back, the current step announced, upcoming steps locked.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Tooltips in four positions that open on hover, tap and keyboard focus, and close with Escape, as WCAG requires.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component