Files
2nd/10_Wiki/Dev/Topic_HOWTO/HOWTO_CSS_Aspect_Ratio.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.6 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
howto-css-aspect-ratio How To - CSS Aspect Ratio Web_Recipes draft conceptual
padding-top aspect ratio hack
aspect-ratio property
B 0.83 2026-07-04 2026-07-04
howto
css
w3schools
layout
responsive
https://www.w3schools.com/howto/howto_css_aspect_ratio.asp

HOWTO CSS Aspect Ratio

🎯 한 줄 통찰 (One-line insight)

The classic aspect-ratio hack exploits a CSS quirk that trips up many developers the first time they see it: percentage padding-top on a block element is calculated relative to the PARENT'S WIDTH, not its own height — which is precisely why padding-top: 56.25% (9÷16) produces a perfect 16:9 box regardless of how wide the container actually is, before the modern aspect-ratio property existed to make the intent explicit and readable. [S1]

🧠 핵심 개념 (Core concepts)

  • Percentage padding-top hackpadding-top: X% on a full-width block is computed against the element's OWN WIDTH (since padding percentages always resolve against the containing block's width), so setting it to a ratio-derived percentage locks the height to a fixed proportion of the width. [S1]
  • Ratio-to-percentage formulas: 1:1 → 100%; 16:9 → 56.25% (9÷16); 4:3 → 75% (3÷4); 3:2 → 66.66% (2÷3); 8:5 → 62.5% (5÷8). [S1]
  • position: relative + absolutely-positioned child — needed if text/content must sit inside the ratio-locked box, since the box itself has no "real" height from content. [S1]
  • Modern aspect-ratio propertyaspect-ratio: 3 / 2; directly expresses the same intent in newer browsers (support from roughly Chrome 88 / Firefox 89 / Safari 15 / Edge 88), no padding math required. [S1]

📖 세부 내용 (Details)

  • 1:1 box: .container { width: 100%; padding-top: 100%; position: relative; }. [S1]
  • Text inside a ratio-locked box: .text { position: absolute; top: 0; left: 0; bottom: 0; right: 0; }. [S1]
  • Modern equivalent: .container { aspect-ratio: 3 / 2; }. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

없음 — 신규 레시피, 기존 문서와 모순되는 내용 없음.

🛠️ 적용 사례 (Applied in summary)

16:9, 4:3, 3:2, 8:5 등 여러 비율을 padding-top 백분율로 구현하는 예제들이 원문에서 직접 나란히 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Legacy padding-top hack vs. modern aspect-ratio property (CSS):

/* Legacy hack -- 16:9 */
.container-legacy {
  width: 100%;
  padding-top: 56.25%; /* 9 / 16 */
  position: relative;
}

/* Modern equivalent */
.container-modern {
  aspect-ratio: 16 / 9;
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "How To - Aspect Ratio" recipe (Astra wiki-curation, P-Reinforce v3.1 format).