---
id: wiki-2026-0508-relative-positioning
title: Relative Positioning
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [position-relative, CSS-relative-positioning]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [css, positioning, layout, frontend]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: css
framework: browser-css
---
# Relative Positioning
## 매 한 줄
> **"매 element 의 normal flow 의 위치 의 유지하면서 visual offset 의 적용 + absolute children 의 anchor 의 establish."**. CSS2.1 의 정의된 `position: relative` 의 매 modern layout 의 foundational primitive — flow 의 영향 없이 painting 의 shift, `top/right/bottom/left` 의 offset, containing block 의 establish 로 의 absolute descendant 의 reference frame 의 제공.
## 매 핵심
### 매 정의
- `position: relative` 의 element 의 normal flow 에서 의 그대로 의 space 의 reserve 함.
- `top/left/right/bottom` 의 visual paint 의 offset — 매 layout 의 surrounding 의 영향 없음.
- `z-index` 의 적용 가능 (stacking context 의 establishes when paired with `z-index` 외 의 0).
- Absolute descendants 의 의 nearest positioned ancestor 가 됨.
### 매 vs. 다른 positioning
- `static` (default): offset 의 무시, stacking context 없음.
- `absolute`: flow 에서 의 제거, nearest positioned ancestor 의 anchor.
- `fixed`: viewport 의 anchor.
- `sticky`: relative + scroll-bound 의 hybrid.
### 매 응용
1. Absolute child 의 containment frame 의 establish.
2. Decorative offset (icon nudge, badge placement) 의 layout 의 disturbing 없이.
3. `z-index` 의 stacking context 의 create.
4. Tooltip / dropdown 의 anchor.
## 💻 패턴
### Absolute child 의 containment
```css
.card {
position: relative; /* anchor for .badge */
padding: 1rem;
}
.card .badge {
position: absolute;
top: 0.5rem;
right: 0.5rem;
}
```
### Visual nudge 의 offset (layout 의 영향 없음)
```css
.icon-up {
position: relative;
top: -2px; /* shifts paint, surrounding text unaffected */
}
```
### Stacking context 의 establish
```css
.modal-backdrop {
position: relative;
z-index: 0; /* creates new stacking context */
isolation: isolate; /* modern alternative — no offset needed */
}
```
### Tooltip anchor
```css
.tooltip-host {
position: relative;
display: inline-block;
}
.tooltip-host .tooltip {
position: absolute;
bottom: calc(100% + 4px);
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
}
```
### Sticky alternative 의 비교
```css
/* relative: scrolls with content */
.note { position: relative; top: 10px; }
/* sticky: relative until threshold, then fixed */
.toc { position: sticky; top: 0; }
```
### React + CSS-in-JS (styled-components)
```tsx
const Card = styled.div`
position: relative;
border: 1px solid #ddd;
`;
const Pin = styled.span`
position: absolute;
top: -8px;
left: -8px;
`;
export const PinnedCard = ({ children }: { children: ReactNode }) => (