CSS 초보자λ₯Ό μœ„ν•œ 팁 CSS Shorthand (쀄여쓰기, 속기)

2013. 1. 14. 13:59Β·Before. 2021


퍼블리싱을 ν•™μ›μ—μ„œ λ°°μš°κ±°λ‚˜ μ±…μœΌλ‘œ κ³΅λΆ€ν• λ•Œ CSSλ₯Ό 기본속성 κ°’ κ·ΈλŒ€λ‘œ ν‘œν˜„ν•˜λŠ” 법은 많이 κ°€λ₯΄μΉ˜κ³  책에도 λ‚˜μ™€ μžˆμ§€λ§Œ, CSS Shorthand λŒ€ν•΄μ„  μ‚¬μš©ν•˜λŠ” λ°©λ²•λ§Œ λ‚˜μ™€μžˆμ§€ μ •ν™•ν•œ μˆœμ„œλ‚˜ 원리 원칙에 λŒ€ν•΄ λ‚˜μ™€μžˆλŠ” 것은 보기 νž˜λ“­λ‹ˆλ‹€. κ·Έλž˜μ„œ CSS Shorthand에 λŒ€ν•˜μ—¬ μ •λ¦¬ν•˜κ³  ν•©λ‹ˆλ‹€.
CSS Shorthand, -우리말둜 "쀄여쓰기, 속기"- λŠ” μŠ€νƒ€μΌμ‹œνŠΈμ˜ νŒŒμΌμ„ 쀄여쀄 뿐만 μ•„λ‹ˆλΌ 가독성을 λ†’μ—¬μ£Όκ³  μˆ˜μ •ν• λ•Œμ—λ„ λΉ λ₯΄κ²Œ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

1. Font

font 속성을 μ†κΈ°λ‘œ μ‚¬μš©ν• λ•Œ μ„ μ–Έν•˜μ§€ μ•Šμ€ 값은 κΈ°λ³Έ κ°’μ΄λ©λ‹ˆλ‹€. font의 κΈ°λ³Έ 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - font-style
  • - font-variant
  • - font-weight
  • - font-size
  • - line-height
  • - font-family

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
6
7
8
.element {
    font-style:normal;
    font-variant:normal;
    font-weight:normal;
    font-size:inherit;
    line-height:normal;
    font-family:inherit;
}

CSS Shorthand 적용

1
.element {font:normal normal normal inhert/normal inherit;}

2. Background

배경화면은 단색, μ΄λ―Έμ§€λ“±μœΌλ‘œ μ μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - background-color
  • - background-image
  • - background-repeat
  • - background-position
  • - background-attachment

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
6
7
.element {
    background-color:transparent;
    background-image:none;
    background-repeat:repeat;
    background-position:top left;
    background-attachment:scroll;
}

CSS Shorthand 적용

1
.element {background:transparent url(image.png) repeat top left scroll;}

3. List

λͺ©λ‘μ†μ„±μ€ 단 3κ°€μ§€λ§Œ μžˆμŠ΅λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - list-style-type
  • - list-style-position
  • - list-image

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
.element {
    list-style-type:square;
    list-style-position:inside;
    list-style-image:url(image.png);
}

CSS Shorthand 적용

1
.element {list-style:square inside url(image.png);}

4. border

BorderλŠ” μƒν•˜μ’Œμš°μ˜ 속성을 μ§€λ‹™λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - border-width
  • - border-top
  • - border-top-color
  • - border-top-style
  • - border-top-width
  • - border-style
  • - border-right
  • - border-right-color
  • - border-right-style
  • - border-right-width
  • - border-color
  • - border-bottom
  • - border-bottom-color
  • - border-bottom-style
  • - border-bottom-width
  • - border-left
  • - border-left-color
  • - border-left-style
  • - border-left-width

Border 속성은 μœ„μ™€κ°™μ΄ λ§ŽμŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ 많이 μ‚¬μš©ν•˜λŠ” 것은 νŒŒλž€μƒ‰μœΌλ‘œ μ“°μ—¬μ§„ κΈ€μžλΆ€λΆ„μž…λ‹ˆλ‹€. μœ„3κ°€μ§€ 속성을 μ€„μ—¬μ„œ μ‚¬μš©ν•˜μ‹œλ©΄ 되고 μ‚¬μš©λ°©λ²•μ€ κ°„λ‹΅ν•©λ‹ˆλ‹€.

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
.element {
    border-width:5px;
    border-style:dotted;
    border-color:#000;
}

CSS Shorthand 적용

1
.element {border:5px solid #000;}

5. Marginκ³Ό Padding

Marginκ³Ό Padding은 각각 4κ°€μ§€ μž…λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€. (padding 쀄여쓰기 λ˜ν•œ μ•„λž˜μ™€ λ™μΌν•©λ‹ˆλ‹€.)

  • - margin-top
  • - margin-right
  • - margin-bottom
  • - margin-left
  • - padding-top
  • - padding-right
  • - padding-bottom
  • - padding-left

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
6
.element {
    margin-top:5px;
    margin-right:7px;
    margin-bottom:5px;
    margin-left:7px;
}

CSS Shorthand 적용 (μˆœμ„œλŠ” μœ„ > 였λ₯Έμͺ½ > μ•„λž˜ > μ™Όμͺ½ μˆœμ„œλ‘œ μž‘μ„±ν•©λ‹ˆλ‹€.)

1
.element {margin:5px 7px 5px 7px;}

CSS Shorthand 적용 (margin의 μƒν•˜ 속성이 κ°™κ³ , 쒌우 속성이 κ°™μ„κ²½μš°)

1
.element {margin:5px 7px;}

CSS Shorthand 적용 (margin의 μƒν•˜ 쒌우 속성이 κ°™μ„κ²½μš°)

1
.element {margin:5px;}

6. outline

outline은 element μš”μ†Œ μ£Όλ³€μ˜ ꡬ뢄할 λ•Œ μ‚¬μš©ν•©λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - outline-width
  • - outline-style
  • - outline-color

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
.element {
    outline-width:3px;
    outline-style:dotted;
    outline-color:#000;
}

CSS Shorthand 적용

1
.element {outline:3px dotted #000;}

7. Transition

Transition은 CSS LEVEL3 으둜 마우슀 μ΄λ²€νŠΈμ— μ˜ν•œ 동적인 μš”μ†Œλ₯Ό ν‘œν˜„ν•˜κ³ μž ν•  λ•Œ 주둜 μ‚¬μš©λ©λ‹ˆλ‹€. 속성은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

  • - transition-property
  • - transition-timing-function
  • - transition-delay

쀄여쓰지 μ•Šκ³  속성 적용

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
transition-property:all;
transition-duration:3s;
transition-timing-function:ease-in;
transition-delay:2s;
 
/* 파폭 4 */
-moz-transition-property:all;
-moz-transition-duration:3s;
-moz-transition-timing-function:ease-in;
-moz-transition-delay:2s;
 
/* 크둬과 μ‚¬νŒŒλ¦¬ */
-webkit-transition-property:all;
-webkit-transition-duration:3s;
-webkit-transition-timing-function:ease-in;
-webkit-transition-delay:2s;
 
/* 였페라 */
-o-transition-property:all;
-o-transition-duration:3s;
-o-transition-timing-function:ease-in;
-o-transition-delay:2s;

CSS Shorthand 적용

1
2
3
4
5
6
7
8
9
10
transition:all 3s ease-in 2s;
 
/* 파폭 4 */
-moz-transition:all 3s ease-in 2s;
 
/* 크둬과 μ‚¬νŒŒλ¦¬ */
-webkit-transition:all 3s ease-in 2s;
 
/* 였페라 */
-o-transition:all 3s ease-in 2s;

마치며

CSS μ€„μ—¬μ“°κΈ°λŠ” λ¬Έλ²•μ μœΌλ‘œ κ°•μ œμ„±μ„ κ°€μ§€μ§€λŠ” μ•ŠμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μž‘μ„±μ‹œ μ‹œκ°„μ ˆμ•½κ³Ό CSS크기λ₯Ό 쀄일 수 μžˆμŠ΅λ‹ˆλ‹€.
λ˜ν•œ μ € 같은 κ²½μš°λŠ” 쀄여쓰기λ₯Ό 자주 μ‚¬μš©ν•˜λŠ” νŽΈμž…λ‹ˆλ‹€. κ·Έλž˜μ„œ μœ„μ™€ 같이 μ •λ¦¬ν•˜μ˜€μœΌλ‹ˆ CSSμž‘μ„±ν•˜μ‹€ λ•Œ λ§Žμ€ 도움이 λ˜μ—ˆμœΌλ©΄ ν•©λ‹ˆλ‹€.




원문 : http://biew.co.kr/19

μ €μž‘μžν‘œμ‹œ (μƒˆμ°½μ—΄λ¦Ό)

'Before. 2021' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

λΈŒλΌμš°μ € μ‚¬μš©μœ¨ 쑰사!  (0) 2013.02.27
[CSS]IE6, 7을 μœ„ν•΄μ„œ ν•˜μ§€λ§μ•„μ•Όν•  것듀  (0) 2013.01.18
IE버전 κ°•μ œ λ³€ν™˜μš© λ©”νƒ€νƒœκ·Έ  (2) 2013.01.10
ν…μŠ€νŠΈ μ€„λ°”κΏˆ νƒœκ·Έ  (0) 2012.12.21
CSS3 box-Shadow  (0) 2012.12.13
'Before. 2021' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€
  • λΈŒλΌμš°μ € μ‚¬μš©μœ¨ 쑰사!
  • [CSS]IE6, 7을 μœ„ν•΄μ„œ ν•˜μ§€λ§μ•„μ•Όν•  것듀
  • IE버전 κ°•μ œ λ³€ν™˜μš© λ©”νƒ€νƒœκ·Έ
  • ν…μŠ€νŠΈ μ€„λ°”κΏˆ νƒœκ·Έ
빙고ꡬ맛탕
빙고ꡬ맛탕
μ›ΉνΌλΈ”λ¦¬μ…”λ‘œ μ‹œμž‘ν•΄ ν”„λ‘ νŠΈμ—”λ“œ 개발자둜 μ„±μž₯ν•˜κΈ°κΉŒμ§€μ˜ 여정을 λ‹΄λ‹€.
  • 빙고ꡬ맛탕
    π•Žπ”Όπ”Ή 𝔸𝕃𝕃 𝕃𝕆𝔾
    빙고ꡬ맛탕
  • 전체
    였늘
    μ–΄μ œ
    • 전체보기 (40)
      • Before. 2021 (40)
  • 졜근 κΈ€

  • hELLOΒ· Designed Byμ •μƒμš°.v4.10.2
빙고ꡬ맛탕
CSS 초보자λ₯Ό μœ„ν•œ 팁 CSS Shorthand (쀄여쓰기, 속기)
μƒλ‹¨μœΌλ‘œ

ν‹°μŠ€ν† λ¦¬νˆ΄λ°”