9609c04755
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>
116 lines
5.2 KiB
Markdown
116 lines
5.2 KiB
Markdown
---
|
|
id: css-z-index
|
|
title: "CSS Z-index"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["z-index", "stack order", "stacking order", "CSS z index", "layer order", "stacking context"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.88
|
|
created_at: 2026-06-23
|
|
updated_at: 2026-06-23
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["css", "web", "frontend", "w3schools", "position", "z-index"]
|
|
raw_sources: ["https://www.w3schools.com/css/css_z-index.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[CSS Z-index]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
The `z-index` property sets the stack order of positioned elements — higher values render in front of lower ones — and it only works on positioned elements and flex items. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **stack order** — `z-index` specifies the stack order of positioned elements, determining which elements appear in front of or behind others. [S1]
|
|
- **positive or negative** — elements can have positive or negative z-index values. [S1]
|
|
- **higher wins** — higher z-index values always appear above lower ones. [S1]
|
|
- **only on positioned elements** — z-index only works on positioned elements (`position: absolute`, `position: relative`, `position: fixed`, or `position: sticky`) and flex items. [S1]
|
|
- **default order** — without a z-index, elements render in HTML source order. [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **Send behind with negative z-index** — give an absolutely positioned element `z-index: -1` to render it behind text/content. [S1]
|
|
- **Explicit layering** — assign ascending z-index values to sibling boxes to control which overlaps which, independent of source order. [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
**CSS The z-index Property** [S1]
|
|
`z-index` specifies the stack order of positioned elements, determining which elements appear in front or behind others. Elements can have positive or negative z-index values.
|
|
|
|
**Note:** z-index only works on positioned elements (`position: absolute`, `position: relative`, `position: fixed`, or `position: sticky`) and flex items. [S1]
|
|
|
|
**First example — negative z-index puts an image behind text** [S1]
|
|
The CSS rule uses `position: absolute`, `left: 0px`, `top: 0px`, and `z-index: -1`. The HTML includes a heading "This is a heading". The image with z-index of -1 renders behind the text. The page did not provide the full verbatim CSS rule block — Not found in source.
|
|
|
|
**Second example — higher z-index appears above lower** [S1]
|
|
CSS classes defined:
|
|
- `.container` with `position: relative`
|
|
- `.black-box` with `z-index: 1`, plus border and margins
|
|
- `.gray-box` with `z-index: 3`, light gray background
|
|
- `.green-box` with `z-index: 2`, light green background
|
|
|
|
HTML structure: a container div holding three nested divs representing the three boxes. The gray box (z-index 3) sits on top, then green (2), then black (1). The full verbatim CSS/HTML block was not provided in the fetched source — Not found in source.
|
|
|
|
**Third example — rendering order without z-index** [S1]
|
|
Code identical to the second example but omitting all z-index declarations, showing that elements render in HTML source order.
|
|
|
|
**Property reference** [S1]
|
|
|
|
| Property | Description |
|
|
|----------|-------------|
|
|
| z-index | Sets the stack order of an element |
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The page's applied examples are: an image sent behind a heading via `z-index: -1`; three overlapping boxes layered by ascending z-index (gray 3 on top, green 2, black 1); and the same three boxes without z-index to show default source-order stacking. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Send a positioned element behind content (language: CSS):
|
|
```css
|
|
img {
|
|
position: absolute;
|
|
left: 0px;
|
|
top: 0px;
|
|
z-index: -1;
|
|
}
|
|
```
|
|
|
|
Layer sibling boxes by explicit stack order (language: CSS):
|
|
```css
|
|
.container {
|
|
position: relative;
|
|
}
|
|
.black-box {
|
|
z-index: 1;
|
|
}
|
|
.green-box {
|
|
z-index: 2;
|
|
}
|
|
.gray-box {
|
|
z-index: 3;
|
|
}
|
|
```
|
|
Note: the page described these declarations but did not present the complete rule blocks verbatim; the snippets above reflect the described properties — additional rule details Not found in source. [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.88
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[CSS Tutorial]]
|
|
- **관련 개념:** [[CSS Position Fixed and Absolute]], [[CSS Position Sticky]], [[CSS Position Offsets]]
|
|
- **참조 맥락:** Referenced whenever positioned elements overlap and their front-to-back order must be controlled.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — CSS Z-index — https://www.w3schools.com/css/css_z-index.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Z-index" page (Astra wiki-curation, P-Reinforce v3.1 format).
|