πŸ’» Programming/CSS

[CSS] 11. Table ( ν…Œμ΄λΈ” μ„€μ • )

이번 ν¬μŠ€νŒ…μ—μ„œλŠ” CSSλ₯Ό μ΄μš©ν•œ ν…Œμ΄λΈ” κ΄€λ ¨ 속성을 μ„€μ •ν•˜λŠ” 것을 μ•Œμ•„λ³΄λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€.

ν…Œμ΄λΈ” κ΄€λ ¨ μ†μ„±μ—λŠ” λ‹€μŒκ³Ό 같은 것듀이 μžˆμŠ΅λ‹ˆλ‹€. 

  • border-collapse

  • border-spacing 

  • caption-side 

  • empty-cells 

  • table-layout 

 

이제 이 속성듀을 μ–΄λ–»κ²Œ μ‚¬μš©ν•˜λŠ”μ§€ ν•œλ²ˆ λ³ΌκΉŒμš”??? ^-^ 

The border-collapse Property:

이 속성은 λ‹€μŒ 두가지 값을 κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€. collapse 와 separate.  

λ‹€μŒμ€ 두 가지 값에 λŒ€ν•œ μ˜ˆμ œμž…λ‹ˆλ‹€. 

<style type="text/css">
table.one {border-collapse:collapse;}
table.two {border-collapse:separate;}
td.a {
      border-style:dotted; 
      border-width:3px; 
      border-color:#000000; 
      padding: 10px;
}
td.b {border-style:solid; 
      border-width:3px; 
      border-color:#333333; 
      padding:10px;
}
</style>
<table class="one">
<caption>Collapse Border Example</caption>
<tr><td class="a"> Cell A Collapse Example</td></tr>
<tr><td class="b"> Cell B Collapse Example</td></tr>
</table>
<br />
<table class="two">
<caption>Separate Border Example</caption>
<tr><td class="a"> Cell A Separate Example</td></tr>
<tr><td class="b"> Cell B Separate Example</td></tr>
</table>

직접 ν…ŒμŠ€νŠΈ ν•΄λ³΄μ„Έμš”.

 

Collapse 속성값을 주게되면 ν…Œμ΄λΈ” λ‚΄μ˜ μ…€λ“€μ˜ 보더가 λΆ™μ–΄μžˆμ„ 경우 ν•œμ€„λ‘œ 보이게 λ©λ‹ˆλ‹€.

λ°˜λŒ€λ‘œ separate속성값을 주게되면 λΆ™μ–΄μžˆλŠ” 두 μ…€μ˜ 보더가 λ”°λ‘œ λ–¨μ–΄μ Έμ„œ 보이게 λ©λ‹ˆλ‹€.

 

 

 

The border-spacing Property:

이 속성은 보더 μ‚¬μ΄μ˜ 간격을 λ„μš°λŠ” μ†μ„±μž…λ‹ˆλ‹€. μ†μ„±κ°’μœΌλ‘œλŠ” ν•˜λ‚˜ λ˜λŠ” λ‘κ°œμ˜ 값을 κ°€μ§ˆ 수 있고, 이 값은 길이의 λ‹¨μœ„μ—¬μ•Ό ν•©λ‹ˆλ‹€.

값을 ν•˜λ‚˜λ§Œ 쀄 κ²½μš°μ—λŠ” κ°€λ‘œ, μ„Έλ‘œμ— λ™μΌν•œ 값이 적용이 되며 λ‘κ°œμ˜ 값을 쀄 κ²½μš°μ—λŠ” 첫째값이 κ°€λ‘œ 슀페이슀, λ‘λ²ˆμ§Έ 값이 μ„Έλ‘œ 슀페이슀λ₯Ό μœ„ν•œ κ°’μœΌλ‘œ κ°„μ£Όλ©λ‹ˆλ‹€.

NOTE: Netscape 7 λ˜λŠ” IE 6 μ—μ„œλŠ” μ μš©λ˜μ§€ μ•ŠλŠ”λ‹€κ³  ν•˜λ„€μš”. 아직도 IE 6 μ‚¬μš©ν•˜λŠ” μ‚¬λžŒμ΄ μžˆμ„μ§€λŠ” μ˜λ¬Έμ΄μ§€λ§Œμš”. 

<style type="text/css">
/* If you provide one value */
table.example {border-spacing:10px;}
/* This is how you can provide two values */
table.example {border-spacing:10px; 15px;}
</style>

μ•žμ„œ ν–ˆλ˜ 예제의 μ†ŒμŠ€λ₯Ό 변경해보도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€. 

<style type="text/css">
table.one {
   border-collapse:separate;
   width:400px;
   border-spacing:10px;
}
table.two {
   border-collapse:separate;
   width:400px;
   border-spacing:10px 50px;
}
</style>
<table class="one" border="1">
<caption>Separate Border Example with border-spacing</caption>
<tr><td> Cell A Collapse Example</td></tr>
<tr><td> Cell B Collapse Example</td></tr>
</table>
<br />
<table class="two" border="1">
<caption>Separate Border Example with border-spacing</caption>
<tr><td> Cell A Separate Example</td></tr>
<tr><td> Cell B Separate Example</td></tr>
</table>

κ²°κ³ΌλŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

 

직접 ν…ŒμŠ€νŠΈ ν•΄λ³΄λŠ” 것 μžŠμ§€ λ§ˆμ„Έμš”. κΌ­ μ΄μš”!!! ^-^ 

 

The caption-side Property:

이 속성은 μΊ‘μ…˜μ„ 어디에 μœ„μΉ˜μ‹œν‚¬ 것인지에 λŒ€ν•œ μ†μ„±μž…λ‹ˆλ‹€. μ†μ„±κ°’μœΌλ‘œλŠ” λ‹€μŒ 넀가지 쀑 ν•œκ°œλ₯Ό κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€. top, bottom, left or right.  그럼 각각의 예제λ₯Ό ν•œλ²ˆ λ³ΌκΉŒμš”?? 

NOTE: IE μ—μ„œλŠ” μž‘λ™μ„ μ•ˆν•  수 μžˆλ‹€λŠ” κ΅°μš”.

<style type="text/css">
caption.top {caption-side:top}
caption.bottom {caption-side:bottom}
caption.left {caption-side:left}
caption.right {caption-side:right}
</style>

<table style="width:400px; border:1px solid black;">
<caption class="top">
This caption will appear at the top
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="bottom">
This caption will appear at the bottom
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="left">
This caption will appear at the left
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="right">
This caption will appear at the right
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>

κ²°κ³ΌλŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

 

 

 

The empty-cells Property:

이 속성은 빈 μ…€κ³Ό κ΄€λ ¨λœ μ†μ„±μž…λ‹ˆλ‹€. μ†μ„±κ°’μœΌλ‘œλŠ” show, hide, inherit 쀑에 ν•˜λ‚˜λ₯Ό κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€. 

<style type="text/css">
table.empty{
    width:350px;
    border-collapse:separate;
    empty-cells:hide;
}
td.empty{
    padding:5px;
    border-style:solid;
    border-width:1px;
    border-color:#999999;
}
</style>
<table class="empty">
<tr>
<th></th>
<th>Title one</th>
<th>Title two</th>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty">value</td>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty"></td>
</tr>
</table>

 

 

κ²°κ³ΌλŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€. 

 

 

 

The table-layout Property:

이 속성은 λΈŒλΌμš°μ €μ— ν…Œμ΄λΈ”μ„ 보여쀄 λ•Œ μ–΄λ–»κ²Œ 보여쀄 것인지λ₯Ό 컨트둀 ν•  수 있게 ν•΄μ£ΌλŠ” μ†μ„±μž…λ‹ˆλ‹€. μ†μ„±κ°’μœΌλ‘œλŠ” fixed, auto, λ˜λŠ” inherit 을 κ°€μ§ˆ 수 μžˆμŠ΅λ‹ˆλ‹€.

 

세가지 값에 λŒ€ν•œ 차이점을 ν•œλ²ˆ μ•Œμ•„λ³΄λ„λ‘ ν•˜μ£ . 

NOTE: 참고둜 이 속성은 λ§Žμ€ λΈŒλΌμš°μ €μ—μ„œ μ§€μ›ν•˜μ§€ μ•ŠλŠ”λ‹€κ³  ν•©λ‹ˆλ‹€.

<style type="text/css">
table.auto
{
table-layout: auto
}
table.fixed
{
table-layout: fixed
}
</style>
<table class="auto" border="1" width="100%">
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>
<br />
<table class="fixed" border="1" width="100%">
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>

κ²°κ³ΌλŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

 

 

 

 

κΌ­ 슀슀둜 ν…ŒμŠ€νŠΈ 해보고 κ²°κ³Όλ₯Ό ν™•μΈν•˜μ„Έμš”.  

 

λΈŒλΌμš°μ € λ³„λ‘œ 해보고 λΈŒλΌμš°μ €μ˜ λ²„μ „λ³„λ‘œ 해보고 μ—΄μ‹¬νžˆ 곡뢀해야 κ³ μˆ˜κ°€ 될 수 μžˆμŠ΅λ‹ˆλ‹€.

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_tables.htm