Concepts 🚀 Project 🧮 Labs
🧮 Labs / CSS / Modal dialog — overlay + centered box

Modal dialog — overlay + centered box

A dialog that floats above the page. Dark overlay behind, centered white box, close button.

style.css v3.1
style.css — the CSS rules
index.html — the HTML structure (what the CSS targets)
Live preview updates as you type
🧠 How it works

position: fixed + top: 0; width: 100%; height: 100% — the overlay covers the ENTIRE viewport. background: rgba(0,0,0,0.5) — semi-transparent black. Dims the page behind the modal. display: flex + align-items: center + justify-content: center — centers the modal box. z-index: 1000 — modal is above everything else on the page. backdrop-filter: blur(2px) — blurs the content behind the overlay (modern, supported in most browsers). max-width: 500px + width: 90% — responsive: 500px on desktop, 90% on mobile. @keyframes modalIn — the modal scales up from 0.9 to 1.0 with a fade-in. Feels smooth. Structure: header (title + close), body (content), footer (action buttons). Classic dialog pattern.

✏️ Try these changes
  • Change rgba(0,0,0,0.5) to rgba(0,0,0,0.8)
    → darker overlay — more dramatic
  • Change max-width: 500px to 800px
    → wider modal
  • Change the animation duration from 0.2s to 0.5s
    → slower entrance
  • Remove backdrop-filter: blur(2px)
    → no blur behind the modal
  • Change border-radius: 12px to 0
    → sharp corners — more 'system dialog' look