docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,223 @@
|
||||
---
|
||||
id: css-horizontal-navbar
|
||||
title: "CSS Horizontal Navbar"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["horizontal navbar", "top navigation", "horizontal navigation bar", "flex navbar", "float navbar", "sticky navbar"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-06-23
|
||||
updated_at: 2026-06-23
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["css", "web", "frontend", "w3schools", "navbar", "navigation"]
|
||||
raw_sources: ["https://www.w3schools.com/css/css_navbar_horizontal.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSS Horizontal Navbar]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A horizontal navbar lays its list items side by side using either floating list items or a flexbox `<ul>`, then adds hover/active states, dividers, and fixed or sticky positioning. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Float method** — `ul li { float: left; }` with `overflow: hidden` on the `<ul>` lays links horizontally. [S1]
|
||||
- **Flex method** — `display: flex` on the `<ul>` arranges links in a row. [S1]
|
||||
- **Block links** — `display: block` on `a` makes the full link area clickable. [S1]
|
||||
- **Active class** — `a.active` marks the current link with a highlight color. [S1]
|
||||
- **Fixed/sticky positioning** — `position: fixed` (top/bottom) or `position: sticky` (with `top`) keeps the navbar in view while scrolling. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Two layout methods** — floating list items (`float: left`) or a flex container (`display: flex`) both yield a horizontal row. [S1]
|
||||
- **Dividers** — `border-right` on each `li` with `li:last-child { border-right: none; }` removes the trailing divider. [S1]
|
||||
- **Right-aligned item** — `style="float:right"` on a single `<li>` pushes one link to the right. [S1]
|
||||
- **Sticky requires an offset** — at least one of `top`/`right`/`bottom`/`left` must be set for sticky to work. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**Horizontal navbar with float** [S1]
|
||||
```css
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background-color: #333333;
|
||||
}
|
||||
|
||||
ul li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
ul li a {
|
||||
display: block;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul li a:hover {
|
||||
background-color: #111111;
|
||||
}
|
||||
```
|
||||
|
||||
**Horizontal navbar with flex** [S1]
|
||||
```css
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #333333;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
ul li a {
|
||||
display: block;
|
||||
color: white;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul li a:hover {
|
||||
background-color: #111111;
|
||||
}
|
||||
```
|
||||
|
||||
**Horizontal centered navbar with flex** [S1]
|
||||
```css
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #333333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
```
|
||||
|
||||
**Active state** [S1]
|
||||
```css
|
||||
ul li a.active {
|
||||
background-color: #04AA6D;
|
||||
}
|
||||
```
|
||||
|
||||
**Gray horizontal navbar** [S1]
|
||||
```css
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
border: 1px solid #e7e7e7;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
```
|
||||
|
||||
**Right-align the last link** [S1]
|
||||
```html
|
||||
<ul>
|
||||
<li><a href="#home" class="active">Home</a></li>
|
||||
<li><a href="#news">News</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
<li style="float:right"><a href="#about">About</a></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
**Border dividers** [S1]
|
||||
```css
|
||||
/* Add a lightgray right border to all list items, except the last */
|
||||
ul li {
|
||||
float: left;
|
||||
border-right: 1px solid #bbbbbb;
|
||||
}
|
||||
|
||||
ul li:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
```
|
||||
|
||||
**Fixed top navbar** [S1]
|
||||
```css
|
||||
ul {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
**Fixed bottom navbar** [S1]
|
||||
```css
|
||||
ul {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
**Note** [S1]
|
||||
Fixed position might not work properly on mobile devices.
|
||||
|
||||
**Sticky navbar** [S1]
|
||||
```css
|
||||
ul {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
```
|
||||
|
||||
**Note** [S1]
|
||||
You must specify at least one of the `top`, `right`, `bottom` or `left` properties, for sticky positioning to work.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's applied examples are the dark float navbar, the flex navbar, the centered flex navbar, the green `.active` link, the gray flex navbar, the right-aligned About link, border dividers, fixed top/bottom navbars, and the sticky navbar. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Float-based horizontal navbar (language: CSS):
|
||||
```css
|
||||
ul li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
ul li a {
|
||||
display: block;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
```
|
||||
Sticky navbar (language: CSS):
|
||||
```css
|
||||
ul {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
- **Float vs Flex layout** — The source presents two methods for laying out a horizontal navbar: floating the list items (`ul li { float: left; }`, with `overflow: hidden` on the `<ul>`) or using a flex container (`display: flex` on the `<ul>`). Both produce a horizontal row of links; the flex method additionally enables `justify-content: center` for easy centering. [S1]
|
||||
- **Fixed vs Sticky positioning** — `position: fixed` pins the navbar to the top or bottom of the viewport (but may not work properly on mobile), while `position: sticky` keeps it in flow until scrolled and requires at least one offset (`top`/`right`/`bottom`/`left`) to work. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
No contradictions found in the source.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[CSS Tutorial]]
|
||||
- **관련 개념:** [[CSS Navigation Bar]], [[CSS Vertical Navbar]], [[CSS Position]], [[CSS Flexbox]]
|
||||
- **참조 맥락:** Referenced when building a top or bottom navigation bar with float or flex layout.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — CSS Horizontal Navbar — https://www.w3schools.com/css/css_navbar_horizontal.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Horizontal Navbar" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user