{
  "id": "shrinking-header",
  "name": "Shrinking Header",
  "category": "effects",
  "tags": [
    "sticky header",
    "shrink on scroll",
    "scroll-driven",
    "navbar",
    "animation-range",
    "scroll timeline"
  ],
  "description": "A sticky header that shrinks, gains a background and casts a shadow over the first 120px of scrolling, in pure CSS.",
  "url": "https://copy-css.com/snippets/shrinking-header",
  "markdown": "https://copy-css.com/snippets/shrinking-header.md",
  "html": "<header class=\"shrink-head\">\n  <a class=\"shrink-head-logo\" href=\"#\">Acme</a>\n  <nav aria-label=\"Main\">\n    <a href=\"#\">Docs</a>\n    <a href=\"#\">Blog</a>\n  </nav>\n</header>",
  "css": ".shrink-head {\n  position: sticky;\n  top: 0;\n  z-index: 10;\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  padding: 22px 20px;\n  color: #0f172a;\n  font-family: system-ui, sans-serif;\n}\n\n.shrink-head-logo {\n  color: inherit;\n  font-size: 24px;\n  font-weight: 800;\n  text-decoration: none;\n}\n\n.shrink-head nav {\n  display: flex;\n  gap: 16px;\n}\n\n.shrink-head nav a {\n  color: #475569;\n  font-size: 14px;\n  font-weight: 600;\n  text-decoration: none;\n}\n\n.shrink-head a:focus-visible {\n  outline: 2px solid #2563eb;\n  outline-offset: 3px;\n  border-radius: 2px;\n}\n\n@supports (animation-timeline: scroll()) {\n  .shrink-head {\n    animation: shrink-head-pad linear both;\n    animation-timeline: scroll();\n    animation-range: 0 120px;\n  }\n\n  .shrink-head-logo {\n    animation: shrink-head-logo linear both;\n    animation-timeline: scroll();\n    animation-range: 0 120px;\n  }\n}\n\n@keyframes shrink-head-pad {\n  to {\n    padding-block: 10px;\n    background: rgba(255, 255, 255, 0.9);\n    box-shadow: 0 4px 16px -8px rgba(15, 23, 42, 0.3);\n  }\n}\n\n@keyframes shrink-head-logo {\n  to {\n    font-size: 18px;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .shrink-head,\n  .shrink-head-logo {\n    animation: none;\n  }\n}",
  "features": [
    "scroll-driven animations",
    "keyframe animations",
    "box shadows",
    "Flexbox",
    "sticky positioning",
    "keyboard focus styles",
    "reduced-motion support"
  ],
  "customProperties": []
}
