---
id: howto-css-fixed-sidebar
title: "How To - Fixed Sidebar"
category: "Web_Recipes"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["sidenav CSS", "fixed side navigation"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.83
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["howto", "css", "w3schools", "layout", "position", "navigation", "sidebar"]
raw_sources: ["https://www.w3schools.com/howto/howto_css_fixed_sidebar.asp"]
applied_in: []
github_commit: ""
---

# [[HOWTO CSS Fixed Sidebar]]

## 🎯 한 줄 통찰 (One-line insight)
Just like the fixed-top-menu recipe, this pattern requires the SAME manual "keep two numbers in sync" discipline — the sidebar's `width` and the main content's `margin-left` must match exactly, or the content either overlaps the sidebar (margin too small) or leaves an awkward gap (margin too large); `z-index: 1` is also added here specifically because the sidebar sits alongside scrollable content rather than above/below it, making stacking order collisions more likely than in the top/bottom fixed-menu case. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`position: fixed; top: 0; left: 0;`** — pins the sidebar to the left edge of the viewport. [S1]
- **`z-index: 1`** — ensures the sidebar stays above other page content in stacking order. [S1]
- **`overflow-x: hidden`** — prevents horizontal scrollbars from appearing inside the fixed sidebar. [S1]
- **Matching `margin-left` on `.main`** — must equal the sidebar's declared `width` (e.g. both `160px`) to avoid overlap. [S1]
- **Full-height vs. auto-height variants** — `height: 100%` makes the sidebar span the entire viewport height; omitting it lets the sidebar size to its own content instead. [S1]
- **Small-screen responsiveness** — `@media screen and (max-height: 450px)` reduces padding/font-size on short viewports (not a width breakpoint — a HEIGHT breakpoint, unusual compared to most responsive recipes in this cookbook). [S1]

## 📖 세부 내용 (Details)
- Full example: `.sidenav { height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; padding-top: 20px; } .sidenav a { padding: 6px 8px 6px 16px; color: #818181; display: block; } .main { margin-left: 160px; padding: 0px 10px; }`. [S1]
- Short-viewport adjustment: `@media screen and (max-height: 450px) { .sidenav { padding-top: 15px; } .sidenav a { font-size: 18px; } }`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
없음 — 신규 레시피, 기존 문서와 모순되는 내용 없음.

## 🛠️ 적용 사례 (Applied in summary)
About/Services/Clients/Contact 링크가 담긴 좌측 고정 사이드바를 만들고, 본문에 동일한 margin-left를 줘 겹치지 않게 하는 예제가 원문에서 직접 제시됨. [S1]

## 💻 코드 패턴 (Code patterns)
Fixed sidebar with matching content margin (CSS):
```css
.sidenav {
  height: 100%;
  width: 160px;
  position: fixed;
  z-index: 1;
  top: 0; left: 0;
  overflow-x: hidden;
}
.main {
  margin-left: 160px; /* must match sidenav width */
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
- **신뢰 점수:** 0.83
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[W3Schools HOW TO]]
- **관련 개념:** [[HOWTO CSS Fixed Menu]], [[HOWTO JS Sidenav]], [[HOWTO CSS Sidebar Responsive]]
- **참조 맥락:** CSS Layout & Positioning 섹션.

## 📚 출처 (Sources)
- [S1] W3Schools — How To - Fixed Sidebar — https://www.w3schools.com/howto/howto_css_fixed_sidebar.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "How To - Fixed Sidebar" recipe (Astra wiki-curation, P-Reinforce v3.1 format).
