Notice
Recent Posts
Recent Comments
Link
Β«   2026/05   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Tags
more
Archives
Today
Total
관리 메뉴

η„‘μ œ

transform 속성과 functions (ν•¨μˆ˜) λ³Έλ¬Έ

<style>

transform 속성과 functions (ν•¨μˆ˜)

yo-u-loo 2026. 3. 26. 12:43

 

🟒 transform

μš”μ†Œμ˜ λͺ¨μ–‘, μœ„μΉ˜, 크기, νšŒμ „, 기울기 등을 μ‹œκ°μ μœΌλ‘œ λ³€κ²½ν•  λ•Œ μ‚¬μš©ν•˜λŠ” 속성.

 

β—Ό functions

속성 κ°’(크기, 색상, μœ„μΉ˜ λ“±)을 λ™μ μœΌλ‘œ κ³„μ‚°ν•˜κ±°λ‚˜ λ³€ν™˜ν•˜λŠ” ν•¨μˆ˜ μ—­ν• .

 

1️⃣ μˆ˜ν•™μ  계산 ν•¨μˆ˜

πŸ”Ή calc()

μ„œλ‘œ λ‹€λ₯Έ λ‹€μ–‘ν•œ λ‹¨μœ„μ˜ 값을 μ„žμ–΄μ„œ μ‚¬μΉ™μ—°μ‚°μœΌλ‘œ 계산. (px, %, em, rem, deg, s λ“±)

/* 전체 λ„ˆλΉ„μ—μ„œ 100px을 λΊ€ λ‚˜λ¨Έμ§€ */
.functions {
  width: calc(100% - 100px); 
}
  • 주의: μ—°μ‚°μž μ•žλ’€μ—λŠ” λ°˜λ“œμ‹œ 곡백 ν‘œμ‹œ.

 

πŸ”Ή min() / max()

μ—¬λŸ¬ κ°’ 쀑 κ°€μž₯ μž‘κ±°λ‚˜ κ°€μž₯ 큰 값을 선택.

/* 100%와 700px 쀑 더 μž‘μ€ 값을 선택 */
.functions {
  width: min(100%, 700px);
}

/* 3vw, 2em 쀑 큰 κ°’ */
.functions {
  font-size: max(3vw, 2em);
}

 

πŸ”Ή clamp()

μ΅œμ†Œ, 졜적, μ΅œλŒ€ 값을 μ„€μ •ν•˜μ—¬ λ°˜μ‘ν˜• 크기λ₯Ό ν•œ μ€„λ‘œ μ •μ˜.

.container {
  /* 폰트 크기λ₯Ό μ΅œμ†Œ 16px, μ΅œλŒ€ 32px μ‚¬μ΄μ—μ„œ μœ λ™μ μœΌλ‘œ 쑰절 */
  font-size: clamp(16px, 5vw, 32px); 
}

 


 

2️⃣ μš”μ†Œ λ³€ν˜• ν•¨μˆ˜

πŸ”Ή translate(x, y, z)

μš”μ†Œλ₯Ό ν˜„μž¬ μœ„μΉ˜μ—μ„œ μ§€μ •ν•œ 거리만큼 이동. (px, %)

.move-box {
  width: 100px;
  height: 100px;
  background-color: #ff6b6b;
  transition: transform 0.3s;
}

/* 마우슀λ₯Ό 올리면 였λ₯Έμͺ½μœΌλ‘œ 50px, μœ„μͺ½μœΌλ‘œ 20px 이동 */
.move-box:hover {
  transform: translate(50px, -20px);
}
  • x: μˆ˜ν‰ 이동 거리. (였λ₯Έμͺ½μ€ +, μ™Όμͺ½μ€ -)
  • y: 수직 이동 거리. (μ•„λž˜λŠ” +, μœ„λŠ” -)
  • z: 깊이 λ°©ν–₯ 이동 거리. (3D ν™˜κ²½μ—μ„œ μ•žμ€ +, λ’€λŠ” -)

 

πŸ”Ή rotate(x, y,z, 각도)

μš”μ†Œλ₯Ό μ§€μ •ν•œ κ°λ„λ§ŒνΌ νšŒμ „. (deg)

.rotate-box {
  width: 100px;
  height: 100px;
  background-color: #feca57;
  transition: transform 0.5s;
}

/* 마우슀λ₯Ό 올리면 μ‹œκ³„ λ°©ν–₯으둜 45도 νšŒμ „ */
.rotate-box:hover {
  transform: rotate(45deg);
}
  • μ‹œκ³„ λ°©ν–₯(μ–‘μˆ˜) λ˜λŠ” μ‹œκ³„ λ°˜λŒ€ λ°©ν–₯(음수)으둜 λŒλ¦°λ‹€.

 

πŸ”Ή scale(x, y, z)

μš”μ†Œλ₯Ό μ§€μ •ν•œ 배수만큼 ν™•λŒ€ λ˜λŠ” μΆ•μ†Œ.

.scale-box {
  width: 100px;
  height: 100px;
  background-color: #4ecdc4;
  transition: transform 0.3s;
}

/* 마우슀λ₯Ό 올리면 전체 크기가 1.2λ°° 컀짐 */
.scale-box:hover {
  transform: scale(1.2);
}

/* 팁: κ°€λ‘œλ§Œ ν‚€μš°κ³  μ‹Άλ‹€λ©΄ scaleX(1.5), μ„Έλ‘œλ§Œ ν‚€μš°κ³  μ‹Άλ‹€λ©΄ scaleY(1.5) */
  • 1이 기쀀이며, 1.5λŠ” 150%, 0.5λŠ” 50% 크기λ₯Ό 의미.

 

πŸ”Ή skew(x, y, 각도)

μš”μ†Œλ₯Ό μ§€μ •ν•œ κ°λ„λ§ŒνΌ λΉ„ν‹€μ–΄ μ™œκ³‘. (deg)

.skew-box {
  width: 100px;
  height: 100px;
  background-color: #a29bfe;
  transition: transform 0.3s;
}

/* 마우슀λ₯Ό 올리면 XμΆ• λ°©ν–₯으둜 20도 κΈ°μšΈμ–΄μ§ */
.skew-box:hover {
  transform: skewX(20deg);
}
  • 면을 μž‘μ•„λ‹Ήκ²¨ ν‰ν–‰μ‚¬λ³€ν˜• ν˜•νƒœλ‘œ μ™œκ³‘.

 

 

πŸ”¨ λ³€ν˜• 볡합 효과

μ—¬λŸ¬ 효과λ₯Ό λ™μ‹œμ— μ£Όκ³  싢을 λ•Œ 곡백 ν•œ 칸을 λ„μš°κ³  λ‚˜μ—΄.

.box:hover {
  /* 였λ₯Έμͺ½μœΌλ‘œ 20px μ΄λ™ν•˜κ³  45도 νšŒμ „ν•˜λ©° 1.2λ°° ν™•λŒ€ */
  transform: translate(20px, 0) rotate(45deg) scale(1.2);
}

 


 

πŸ“‹ transform ν•¨μˆ˜ μš”μ•½ν‘œ πŸ“‹

ν•¨μˆ˜ μ—­ν•  λ‹¨μœ„ μ˜ˆμ‹œ
translate μœ„μΉ˜ 이동 px, % translateX(50px)
scale 크기 쑰절 배수(숫자) scale(1.5)
rotate νšŒμ „ deg rotate(180deg)
skew 기울기(λΉ„ν‹€κΈ°) deg skewY(20deg)

 


 

3️⃣ 색상 및 κ·Έλž˜λ””μ–ΈνŠΈ ν•¨μˆ˜

.hero {
  /* 였λ₯Έμͺ½ μ•„λž˜ λ°©ν–₯으둜 νŒŒλž€μƒ‰μ—μ„œ λ³΄λΌμƒ‰μœΌλ‘œ λ³€ν•˜λŠ” λ°°κ²½ */
  background: linear-gradient(to bottom right, blue, purple);
  color: rgba(255, 255, 255, 0.8); /* 80% 투λͺ…ν•œ 흰색 */
}

πŸ”Ή linear-gradient(): μ„ ν˜• κ·Έλž˜λ””μ–ΈνŠΈ 배경을 λ§Œλ“ λ‹€.

πŸ”Ή radial-gradient(): μ›ν˜• κ·Έλž˜λ””μ–ΈνŠΈ 배경을 λ§Œλ“ λ‹€.

πŸ”Ή rgb() / rgba(): 적, λ…Ή, 청색(r, g, b)κ³Ό 투λͺ…도(a)둜 색을 λ§Œλ“ λ‹€.

πŸ”Ή hsl() / hsla(): 색상, 채도, λͺ…λ„λ‘œ 색을 μ‘°μ ˆν•˜μ—¬ 색 λ³€ν˜•μ„ ν•œλ‹€.

 


 

4️⃣ 기타 μœ μš©ν•œ ν•¨μˆ˜

/* 루트 μš”μ†Œμ— CSS λ³€μˆ˜(μ»€μŠ€ν…€ ν”„λ‘œνΌν‹°) μ •μ˜ */
:root {
  --main-color: #3498db; /* 메인 색상을 νŒŒλž€μƒ‰ κ³„μ—΄λ‘œ μ„€μ • */
}

/* .button 클래슀 μŠ€νƒ€μΌ */
.button {
  background-color: var(--main-color); /* μœ„μ—μ„œ μ •μ˜ν•œ λ³€μˆ˜λ₯Ό λΆˆλŸ¬μ™€ λ°°κ²½μƒ‰μœΌλ‘œ μ‚¬μš© */
  background-image: url('pattern.png'); /* λ°°κ²½ μ΄λ―Έμ§€λ‘œ pattern.png 적용 */
}

/* .button μš”μ†Œ 뒀에 가상 μš”μ†Œ 생성 */
.button::after {
  content: attr(data-label); /* HTML μš”μ†Œμ˜ data-label 속성 값을 ν…μŠ€νŠΈλ‘œ ν‘œμ‹œ */
}

πŸ”Ή var(): μ‚¬μš©μžκ°€ μ •μ˜ν•œ CSS λ³€μˆ˜(Custom Properties) 값을 κ°€μ Έμ˜¨λ‹€.

πŸ”Ή url(): 이미지, 폰트 λ“± μ™ΈλΆ€ λ¦¬μ†ŒμŠ€ 파일의 경둜λ₯Ό μ§€μ •ν•œλ‹€.

πŸ”Ή attr(): HTML μš”μ†Œμ˜ 속성값을 κ°€μ Έμ˜¨λ‹€. (μ œν•œμ )

 

 

πŸ“β€Š POINT πŸ“β€Š

βœ”οΈ transform 은 μš”μ†Œμ˜ 물리적 곡간을 μ°¨μ§€ν•˜μ§€ μ•Šκ³  μ‹œκ°μ μΈ ν˜•νƒœλ§Œ λ°”κΎΌλ‹€. βœ”οΈ

βœ”οΈ calc() λ‚΄μ—μ„œ μ—°μ‚°μž(+, -) μ•žλ’€μ—λŠ” λ°˜λ“œμ‹œ 곡백이 μžˆμ–΄μ•Ό λΈŒλΌμš°μ €κ°€ μ˜¬λ°”λ₯΄κ²Œ μΈμ‹ν•œλ‹€. βœ”οΈ

βœ”οΈ clamp() λŠ” λ―Έλ””μ–΄ 쿼리(@media)λ₯Ό μ€„μ—¬μ£ΌλŠ” ν•¨μˆ˜μ΄λ‹€. βœ”οΈ

 

 

πŸ“‹ μ£Όμš” CSS ν•¨μˆ˜ μš”μ•½ν‘œ πŸ“‹

μΉ΄ν…Œκ³ λ¦¬ λŒ€ν‘œ ν•¨μˆ˜ μš©λ„
μˆ˜ν•™ calc(), clamp() μœ μ—°ν•œ 수치 계산 (λ°˜μ‘ν˜• ν•„μˆ˜)
λ³€ν˜• translate(), rotate() μš”μ†Œμ˜ μœ„μΉ˜ 및 ν˜•νƒœ λ³€κ²½
색상 rgba(), linear-gradient() 색상 μ •μ˜ 및 효과
μ°Έμ‘° var(), url(), attr() μ™ΈλΆ€ κ°’μ΄λ‚˜ λ³€μˆ˜ ν™œμš©

 

'<style>' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

transition 속성  (1) 2026.03.27
Functions의 filter속성과 ν•¨μˆ˜  (0) 2026.03.27
Pseudo-elements (μ˜μ‚¬ μš”μ†Œ)  (0) 2026.03.26
Pseudo-class (μ˜μ‚¬ 클래슀)  (0) 2026.03.26
Attribute Selectors  (0) 2026.03.25