--- id: howto-css-fixed-menu title: "How To - Fixed Menu" category: "Web_Recipes" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["fixed navbar CSS", "sticky top menu"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.84 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["howto", "css", "w3schools", "layout", "position", "navigation"] raw_sources: ["https://www.w3schools.com/howto/howto_css_fixed_menu.asp"] applied_in: [] github_commit: "" --- # [[HOWTO CSS Fixed Menu]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The recipe explicitly warns that a fixed navbar OVERLAYS page content underneath it (since `position: fixed` removes the element from flow, other content doesn't "know" to leave room for it) β€” the fix is a manual `margin-top` on the main content equal to or greater than the navbar's height, meaning every fixed-menu layout requires the developer to keep two separate numbers (navbar height, content margin) in sync by hand, with no built-in mechanism linking them. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`position: fixed; top: 0;`** β€” pins the menu to the top of the VIEWPORT, staying visible during scroll. [S1] - **Overlay problem** β€” a fixed element doesn't push other content down; without compensation, the fixed menu covers the top of the page content. [S1] - **Manual `margin-top` fix** β€” the main content block needs `margin-top` at least equal to the navbar's rendered height to avoid being hidden underneath it. [S1] - **Bottom variant** β€” swapping `top: 0` for `bottom: 0` creates a fixed BOTTOM menu instead, with the equivalent fix being `margin-bottom` on the main content. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Fixed top menu: `.navbar { position: fixed; top: 0; width: 100%; overflow: hidden; background-color: #333; } .navbar a { float: left; padding: 14px 16px; color: #f2f2f2; } .main { margin-top: 30px; }`. [S1] - Fixed bottom menu: `.navbar { position: fixed; bottom: 0; width: 100%; } .main { margin-bottom: 30px; }`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ—†μŒ β€” μ‹ κ·œ λ ˆμ‹œν”Ό, κΈ°μ‘΄ λ¬Έμ„œμ™€ λͺ¨μˆœλ˜λŠ” λ‚΄μš© μ—†μŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) Home/News/Contact 링크가 λ‹΄κΈ΄ 상단 κ³ μ • 메뉴λ₯Ό λ§Œλ“€κ³ , μ½˜ν…μΈ κ°€ κ°€λ €μ§€μ§€ μ•Šλ„λ‘ margin-top을 μΆ”κ°€ν•˜λŠ” μ˜ˆμ œκ°€ μ›λ¬Έμ—μ„œ 직접 μ œμ‹œλ¨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Fixed top navbar requiring a manual content offset (CSS): ```css .navbar { position: fixed; top: 0; width: 100%; background-color: #333; } .main { margin-top: 30px; /* must match or exceed navbar height */ } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference) - **μ‹ λ’° 점수:** 0.84 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[W3Schools HOW TO]] - **κ΄€λ ¨ κ°œλ…:** [[HOWTO CSS Fixed Footer]], [[HOWTO CSS Fixed Sidebar]], [[HOWTO JS Navbar Sticky]] - **μ°Έμ‘° λ§₯락:** CSS Layout & Positioning μ„Ήμ…˜. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” How To - Fixed Menu β€” https://www.w3schools.com/howto/howto_css_fixed_menu.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "How To - Fixed Menu" recipe (Astra wiki-curation, P-Reinforce v3.1 format).