Menu dat in spiegelbeeld sluit
Full menu that unfolds from top to bottom via clip-path and on closing plays exactly the same motion backwards, so the easing is mirrored too: fast out, slow settle; on closing slow start, fast exit. Click halfway and it turns around from there. Web Animations API, with aria-expanded, Escape, focus back to the button and an inert background.
How to use it
- Paste the HTML where the navigation & menus should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Menu dat in spiegelbeeld sluit · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="ecm">
<div class="ecm__kop"><a class="ecm__merk" href="#">Timmerbedrijf Hoekstra</a><button class="ecm__knop" type="button" aria-expanded="false" aria-controls="ecm-menu">Menu</button></div>
<div class="ecm__pagina"><h3 class="ecm__h">Kozijnen, deuren en trappen op maat, uit onze werkplaats in Sneek.</h3><p class="ecm__p">Open het menu en sluit het weer: de beweging loopt exact terug.</p></div>
<nav class="ecm__menu" id="ecm-menu" aria-label="Hoofdmenu" hidden>
<ul class="ecm__l">
<li><a href="#">Projecten</a></li>
<li><a href="#">Werkplaats</a></li>
<li><a href="#">Over Hoekstra</a></li>
<li><a href="#">Offerte aanvragen</a></li>
</ul>
<p class="ecm__tel">Bel ons: 0515 123 456 · ma t/m vr 7:30 tot 16:30</p>
</nav>
</div>
</div>/* Menu dat in spiegelbeeld sluit · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.ecm{position:absolute;inset:0;overflow:hidden;background:#f4f3f1;font-family:'Switzer',system-ui,sans-serif;color:#0a0a0a;container-type:size}
.ecm__kop{position:absolute;top:0;left:0;right:0;z-index:2;display:flex;align-items:center;justify-content:space-between;padding:12px 16px;transition:color .3s}
.ecm__merk{display:inline-flex;align-items:center;min-height:28px;font-size:14px;font-weight:700;color:inherit;text-decoration:none;letter-spacing:-.01em}
.ecm__knop{min-width:72px;padding:7px 12px;border:1px solid currentColor;border-radius:4px;background:transparent;color:inherit;font:600 13px 'Switzer',system-ui,sans-serif;cursor:pointer}
.ecm__knop:focus-visible,.ecm__merk:focus-visible{outline:2px solid #F5480F;outline-offset:3px}
.ecm.is-open .ecm__kop{color:#fff}
.ecm__pagina{position:absolute;left:16px;right:16px;bottom:16px}
.ecm__h{margin:0;max-width:20em;font-size:clamp(17px,5cqw,28px);line-height:1.15;font-weight:600;letter-spacing:-.02em}
.ecm__p{margin:8px 0 0;font-size:13px;color:#6b6862}
.ecm__menu{position:absolute;inset:0;z-index:1;background:#0a0a0a;color:#fff;display:flex;flex-direction:column;justify-content:flex-end;padding:56px 16px 16px;clip-path:inset(0 0 100% 0)}
.ecm__menu[hidden]{display:none}
.ecm__l{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
.ecm__l li{overflow:hidden}
.ecm__l a{display:inline-block;color:#fff;text-decoration:none;font-size:clamp(20px,8cqh,40px);font-weight:600;letter-spacing:-.025em;line-height:1.12;transform:translateY(105%);transition:transform .5s cubic-bezier(.22,1,.36,1),color .2s}
.ecm.is-open .ecm__l a{transform:none}
.ecm.is-open .ecm__l li:nth-child(2) a{transition-delay:.05s,0s}.ecm.is-open .ecm__l li:nth-child(3) a{transition-delay:.1s,0s}.ecm.is-open .ecm__l li:nth-child(4) a{transition-delay:.15s,0s}
.ecm__l a:hover{color:#F5480F}.ecm__l a:focus-visible{outline:2px solid #F5480F;outline-offset:2px}
.ecm__tel{margin:14px 0 0;font-size:12.5px;color:#a9a6a0}
@media (prefers-reduced-motion:reduce){.ecm__l a{transform:none;transition:none}}// Menu dat in spiegelbeeld sluit · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
const box = root.querySelector('.ecm'); if (!box) return;
const knop = box.querySelector('.ecm__knop'), menu = box.querySelector('.ecm__menu'), pagina = box.querySelector('.ecm__pagina');
const rm = matchMedia('(prefers-reduced-motion: reduce)').matches;
// Eén animatie die vooruit (openen) of achteruit (sluiten) speelt: zo is de sluitbeweging het exacte spiegelbeeld,
// inclusief de easing, en draait hij vloeiend om als je halverwege klikt.
let anim = null, open = false;
const maakAnim = () => {
anim = menu.animate([{ clipPath: 'inset(0 0 100% 0)' }, { clipPath: 'inset(0 0 0% 0)' }], { duration: rm ? 1 : 700, easing: 'cubic-bezier(.22,1,.36,1)', fill: 'both' });
anim.pause(); anim.currentTime = 0;
anim.onfinish = () => { if (!open) { menu.hidden = true; } };
};
const zet = o => {
open = o; if (!anim) maakAnim();
knop.setAttribute('aria-expanded', String(o)); knop.textContent = o ? 'Sluiten' : 'Menu';
box.classList.toggle('is-open', o); pagina.inert = o;
if (o) menu.hidden = false;
anim.playbackRate = o ? 1 : -1; anim.play();
if (o) { const a = menu.querySelector('a'); setTimeout(() => a && a.focus({ preventScroll: true }), rm ? 0 : 250); }
};
knop.addEventListener('click', () => zet(!open));
box.addEventListener('keydown', e => { if (e.key === 'Escape' && open) { zet(false); knop.focus({ preventScroll: true }); } });
box.querySelectorAll('a').forEach(a => a.addEventListener('click', e => { e.preventDefault(); if (open && menu.contains(a)) { zet(false); knop.focus({ preventScroll: true }); } }));
}
init(document.querySelector('.jouw-container'));
More navigation & menus
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →