docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
---
|
||||
id: css-image-sprites
|
||||
title: "CSS Image Sprites"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["image sprite", "sprite image", "CSS sprites", "background-position sprite", "navigation sprite"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.89
|
||||
created_at: 2026-06-23
|
||||
updated_at: 2026-06-23
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["css", "web", "frontend", "w3schools", "sprites", "background-position", "performance"]
|
||||
raw_sources: ["https://www.w3schools.com/css/css_image_sprites.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSS Image Sprites]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An image sprite packs many small images into one file, then uses `background-image` plus `background-position` offsets to display just the needed slice — cutting server requests and eliminating hover-load delay. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Image sprite** — a collection of various small images put into one larger image file, called a "sprite image." [S1]
|
||||
- **Why sprites** — using a single sprite reduces the number of server requests and saves bandwidth versus loading many separate images. [S1]
|
||||
- **Two key properties** — sprites are implemented with `background-image` (the sprite file) and `background-position` (which slice to show). [S1]
|
||||
- **Transparent placeholder** — a tiny transparent image (`img_trans.gif`, `1×1`) can act as the element while CSS controls which part of the sprite is visible. [S1]
|
||||
- **Hover without extra loads** — hover effects shift `background-position` (e.g. `45px` down) to a different region of the sprite, so no additional image needs to load. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Slice selection** — fix an element's `width`/`height` to one icon's size and use a negative `background-position` to scroll the sprite so only that icon shows. [S1]
|
||||
- **Shorthand background** — combine file and position in one `background: url('sprite.gif') -47px 0;` declaration. [S1]
|
||||
- **Hover row swap** — keep horizontal offset, change the vertical offset on `:hover` to reveal a second row of the sprite for interactive feedback. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**What is an image sprite?**
|
||||
An image sprite is a collection of various small images put into one larger image file, called a "sprite image." This approach reduces the number of server requests and saves bandwidth. Sprites are implemented with the `background-image` and `background-position` properties. [S1]
|
||||
|
||||
**Example 1 — Basic Image Sprites**
|
||||
Three elements (`#home`, `#prev`, `#next`) each set their own `width`/`height` and reference the same `img_navsprites.gif`, differing only by `background-position` so each shows a different icon. Transparent `1×1` images serve as the element bodies: [S1]
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
#home {
|
||||
width: 46px;
|
||||
height: 44px;
|
||||
background-image: url(img_navsprites.gif);
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
#prev {
|
||||
width: 43px;
|
||||
height: 44px;
|
||||
background-image: url('img_navsprites.gif');
|
||||
background-position: -47px 0;
|
||||
}
|
||||
|
||||
#next {
|
||||
width: 43px;
|
||||
height: 44px;
|
||||
background-image: url('img_navsprites.gif');
|
||||
background-position: -91px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<img id="home" src="img_trans.gif" width="1" height="1">
|
||||
<img id="prev" src="img_trans.gif" width="1" height="1">
|
||||
<img id="next" src="img_trans.gif" width="1" height="1">
|
||||
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
**Example 2 — Navigation List**
|
||||
The sprite is applied to a navigation list (`<ul>`/`<li>`). The list uses relative/absolute positioning to lay items out horizontally, with each item's `left` offset and `background` shorthand isolating its icon from the sprite: [S1]
|
||||
```css
|
||||
#navlist {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#navlist li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
#navlist li, #navlist a {
|
||||
height: 44px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#home {
|
||||
left: 0px;
|
||||
width: 46px;
|
||||
background: url('img_navsprites.gif') 0 0;
|
||||
}
|
||||
|
||||
#prev {
|
||||
left: 60px;
|
||||
width: 43px;
|
||||
background: url('img_navsprites.gif') -47px 0;
|
||||
}
|
||||
|
||||
#next {
|
||||
left: 120px;
|
||||
width: 43px;
|
||||
background: url('img_navsprites.gif') -91px 0;
|
||||
}
|
||||
```
|
||||
|
||||
**Example 3 — Hover Effect**
|
||||
Adds interactivity by shifting `background-position` 45px down (to a hover row of `img_navsprites_hover.gif`) on `:hover`. Because all images preload in one file, there is no loading delay on hover: [S1]
|
||||
```css
|
||||
#home a:hover {
|
||||
background: url('img_navsprites_hover.gif') 0 -45px;
|
||||
}
|
||||
|
||||
#prev a:hover {
|
||||
background: url('img_navsprites_hover.gif') -47px -45px;
|
||||
}
|
||||
|
||||
#next a:hover {
|
||||
background: url('img_navsprites_hover.gif') -91px -45px;
|
||||
}
|
||||
```
|
||||
|
||||
**Advantages highlighted:** a single server request instead of multiple image downloads; reduced bandwidth consumption; and no loading delay on hover effects since all images preload in one file. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's three examples — basic sprite slices, a positioned navigation list, and a hover row swap — are the applied demonstrations. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Display one slice of a sprite (language: CSS):
|
||||
```css
|
||||
#prev {
|
||||
width: 43px;
|
||||
height: 44px;
|
||||
background-image: url('img_navsprites.gif');
|
||||
background-position: -47px 0;
|
||||
}
|
||||
```
|
||||
Hover row swap with the background shorthand (language: CSS):
|
||||
```css
|
||||
#prev a:hover {
|
||||
background: url('img_navsprites_hover.gif') -47px -45px;
|
||||
}
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
No contradictions found in the source.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[CSS Tutorial]]
|
||||
- **관련 개념:** [[CSS Backgrounds]], [[CSS Position]], [[CSS Image Gallery]]
|
||||
- **참조 맥락:** Referenced when optimizing icon/asset delivery by consolidating many images into one file with positioned background slices.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — CSS Image Sprites — https://www.w3schools.com/css/css_image_sprites.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Image Sprites" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user