λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
Before. 2021

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

by 빙고ꡬ맛탕 2013. 1. 14.


퍼블리싱을 ν•™μ›μ—μ„œ λ°°μš°κ±°λ‚˜ μ±…μœΌλ‘œ κ³΅λΆ€ν• λ•Œ 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