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>
132 lines
5.5 KiB
Markdown
132 lines
5.5 KiB
Markdown
---
|
|
id: css-float-examples
|
|
title: "CSS Float Examples"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["float layout", "float columns", "equal width boxes", "images side by side", "CSS float menu"]
|
|
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", "float", "layout"]
|
|
raw_sources: ["https://www.w3schools.com/css/css_float_examples.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[CSS Float Examples]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
With the `float` property it is easy to float boxes of content side by side — combined with `box-sizing: border-box` to keep padding inside the box, `float` builds equal-width columns, image grids, and horizontal menus. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **Floating boxes side by side** — `float: left` lets you position boxes of content next to each other. [S1]
|
|
- **`box-sizing: border-box` is essential** — it makes the padding stay inside the box so the box does not break when padding is added. [S1]
|
|
- **Width determines column count** — `33.33%` makes three boxes; use `25%` for four, `50%` for two, etc. [S1]
|
|
- **Equal heights are a known limitation of float** — a fixed `height` is one workaround, but Flexbox can automatically stretch boxes to be as long as the longest box. [S1]
|
|
- **Float also drives horizontal menus** — `float` can be used with a list of hyperlinks to create a horizontal menu. [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **Equal-width column pattern** — set `box-sizing: border-box` globally, then float each box left with a percentage width and padding. [S1]
|
|
- **Image grid pattern** — the same float + percentage-width + padding recipe applied to image containers. [S1]
|
|
- **Fallback for equal heights** — fix `height` when floats produce uneven box heights; prefer Flexbox for automatic equalization. [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
**Create Equal Width Boxes**
|
|
With the `float` property it is easy to float boxes of content side by side. The `box-sizing` property ensures the padding stays inside the box and that it does not break. [S1]
|
|
```css
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.box {
|
|
float: left;
|
|
width: 33.33%; /* three boxes (use 25% for four, and 50% for two, etc) */
|
|
padding: 50px; /* if you want space between the images */
|
|
}
|
|
```
|
|
|
|
**Images Side By Side**
|
|
The same floating technique displays images in a grid layout. [S1]
|
|
```css
|
|
.img-container {
|
|
float: left;
|
|
width: 33.33%; /* three containers (use 25% for four, and 50% for two, etc) */
|
|
padding: 5px; /* if you want space between the images */
|
|
}
|
|
```
|
|
|
|
**Create Boxes With Equal Heights**
|
|
Floated boxes do not automatically share a height. One workaround is to set a fixed height. [S1]
|
|
```css
|
|
.box {
|
|
height: 500px;
|
|
}
|
|
```
|
|
A better alternative is Flexbox, which can automatically stretch boxes to be as long as the longest box. The page references trying a Flexbox version of the layout. [S1]
|
|
|
|
**Navigation Menu**
|
|
You can also use `float` with a list of hyperlinks to create a horizontal menu. The page does not provide a distinct code block for this example in the fetched source. [S1] — Not found in source (exact menu CSS).
|
|
|
|
**All CSS Float Properties (reference table)** [S1]
|
|
|
|
| Property | Description |
|
|
|----------|-------------|
|
|
| `box-sizing` | Defines how the width and height of an element are calculated: should they include padding and borders, or not |
|
|
| `clear` | Specifies what should happen with the element that is next to a floating element |
|
|
| `float` | Specifies whether an element should float to the left, right, or not at all |
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The page's own applied examples are the equal-width box layout, the side-by-side image grid, the equal-height workaround, and a float-based horizontal menu. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Equal-width float columns (language: CSS):
|
|
```css
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.box {
|
|
float: left;
|
|
width: 33.33%;
|
|
padding: 50px;
|
|
}
|
|
```
|
|
Image grid:
|
|
```css
|
|
.img-container {
|
|
float: left;
|
|
width: 33.33%;
|
|
padding: 5px;
|
|
}
|
|
```
|
|
|
|
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
|
- **Float vs Flexbox for equal heights** — float boxes do not equalize height on their own (requires a fixed `height`), whereas Flexbox can automatically stretch boxes to match the longest box. The page recommends Flexbox as the better alternative. [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 Float]], [[CSS Inline Block]], [[CSS Horizontal Align]], [[CSS Flexbox]]
|
|
- **참조 맥락:** Referenced when building multi-column layouts, image grids, or horizontal menus with the legacy float technique.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — CSS Float Examples — https://www.w3schools.com/css/css_float_examples.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Float Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|