9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
163 lines
4.4 KiB
Markdown
163 lines
4.4 KiB
Markdown
---
|
|
id: wiki-2026-0508-css-media-queries
|
|
title: CSS Media Queries
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Media Query, "@media"]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [css, responsive, media-query, frontend]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: CSS
|
|
framework: none
|
|
---
|
|
|
|
# CSS Media Queries
|
|
|
|
## 매 한 줄
|
|
> **"매 viewport / user preference 의 conditional CSS"**. Media Queries 는 device width, color scheme, motion preference 등 의 condition 의 styling 의 적용. 2026 Container Queries 의 출현 에도 viewport-level adaptation 의 표준.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 query types
|
|
- **Width**: `min-width`, `max-width` — viewport 크기
|
|
- **Orientation**: `portrait`, `landscape`
|
|
- **User preference**: `prefers-color-scheme`, `prefers-reduced-motion`, `prefers-contrast`
|
|
- **Resolution**: `min-resolution: 2dppx` (Retina)
|
|
- **Hover capability**: `hover: hover` vs `hover: none`
|
|
- **Pointer**: `pointer: fine` vs `coarse`
|
|
|
|
### 매 Range syntax (2026 표준)
|
|
```css
|
|
@media (width >= 768px) { ... }
|
|
@media (400px <= width <= 800px) { ... }
|
|
```
|
|
|
|
### 매 Mobile-first vs Desktop-first
|
|
- **Mobile-first** (권장): base = mobile, `min-width` 의 add — 매 cascade 친화적
|
|
- **Desktop-first**: base = desktop, `max-width` 의 override — 매 legacy
|
|
|
|
### 매 응용
|
|
1. Responsive breakpoint.
|
|
2. Dark mode (`prefers-color-scheme`).
|
|
3. Accessibility (`prefers-reduced-motion`).
|
|
4. Print stylesheet (`@media print`).
|
|
5. High-DPI image (Retina).
|
|
|
|
## 💻 패턴
|
|
|
|
### Mobile-first breakpoints
|
|
```css
|
|
/* base: mobile */
|
|
.card { padding: 1rem; font-size: 14px; }
|
|
|
|
@media (width >= 640px) { .card { padding: 1.5rem; } }
|
|
@media (width >= 1024px) { .card { font-size: 16px; } }
|
|
@media (width >= 1440px) { .card { padding: 2rem; } }
|
|
```
|
|
|
|
### Dark mode
|
|
```css
|
|
:root {
|
|
--bg: #fff;
|
|
--fg: #111;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--bg: #0a0a0a;
|
|
--fg: #f5f5f5;
|
|
}
|
|
}
|
|
body { background: var(--bg); color: var(--fg); }
|
|
```
|
|
|
|
### Reduced motion (a11y)
|
|
```css
|
|
.fade { transition: opacity 0.4s ease; }
|
|
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.fade { transition: none; }
|
|
*, *::before, *::after {
|
|
animation-duration: 0.01ms !important;
|
|
animation-iteration-count: 1 !important;
|
|
transition-duration: 0.01ms !important;
|
|
}
|
|
}
|
|
```
|
|
|
|
### Hover-only enhancements
|
|
```css
|
|
@media (hover: hover) and (pointer: fine) {
|
|
.btn:hover { background: #eee; transform: scale(1.02); }
|
|
}
|
|
```
|
|
|
|
### Print stylesheet
|
|
```css
|
|
@media print {
|
|
nav, .ads, .comments { display: none; }
|
|
body { font-size: 12pt; color: #000; background: #fff; }
|
|
a::after { content: " (" attr(href) ")"; }
|
|
}
|
|
```
|
|
|
|
### JS 의 matchMedia
|
|
```js
|
|
const dark = window.matchMedia('(prefers-color-scheme: dark)');
|
|
dark.addEventListener('change', (e) => {
|
|
document.documentElement.dataset.theme = e.matches ? 'dark' : 'light';
|
|
});
|
|
```
|
|
|
|
### Container Query (2026 표준, MQ 와 의 보완)
|
|
```css
|
|
.card-host { container-type: inline-size; }
|
|
|
|
@container (width >= 400px) {
|
|
.card { display: grid; grid-template-columns: 120px 1fr; }
|
|
}
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| Viewport-level layout | Media Query |
|
|
| Component-level adaptation | Container Query |
|
|
| 사용자 preference (dark/motion) | `prefers-*` MQ |
|
|
| JS 의 query check | `matchMedia` |
|
|
| Print styling | `@media print` |
|
|
|
|
**기본값**: mobile-first + range syntax (`width >=`).
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[Responsive Design]]
|
|
- 변형: [[컨테이너 쿼리 (Container Queries)|Container Queries]]
|
|
- 응용: [[Dark Mode]] · [[Accessibility (A11y)|Accessibility]]
|
|
- Adjacent: [[CSS Grid]] · [[Flexbox]] · [[CSS_Architecture_and_Styling|CSS Variables]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: responsive breakpoint, dark mode, a11y motion handling 의 generation.
|
|
**언제 X**: component-level adaptation (Container Query 의 사용).
|
|
|
|
## ❌ 안티패턴
|
|
- **Device-targeted MQ**: `iPhone`, `iPad` 의 device sniff — 매 width-based 의 사용.
|
|
- **너무 many breakpoints**: 5개 이상 의 maintenance hell — 매 3-4개 의 기본.
|
|
- **`prefers-reduced-motion` 의 무시**: a11y 위반.
|
|
- **`max-width` desktop-first**: cascade 의 복잡 — 매 mobile-first.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified (MDN Media Queries, CSS Media Queries Level 4/5).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — MQ patterns + range syntax + container queries |
|