2011년 9월 9일 금요일

테이블에서 table-layout:fixed 적용시 td가 동일한 크기로 나눠질 때

파이어폭스 브라우저 사용시

테이블 table-layout:fixed와 <td>의 속성값인 colspan 혹은 rowspan을  동시 적용했을 때
개별 <td>가 동일한 크기로 나눠진다. 아무리 개별 <td>에 <td width="300"><td width="100">으로 적용해봐도 width값이 변하지 않는다.

그럴 땐, <col width="300"><col width="100">을 적용해야 한다.
<html>
<body>
<table width="400px" cellpadding="0" cellspacing="0" style="table-layout:fixed">
<tr>
   <td colspan="2" bgcolor="red">ABCDEFG</td>
</tr>
<tr><col width="300"><col width="100">
   <td bgcolor="yellow">ABCDEFG</td>
   <td bgcolor="blue">ABCDEFG</td>
</tr>
</table>
</body>
</html>

댓글 3개:

  1. 좋은 정보 감사합니다~

    답글삭제
  2. 감사합니다 ^^;;
    http://stackoverflow.com/questions/10712839/styling-a-table-layout-fixed-fixed-width-columns-colspan

    여기에 보면 _table_ _col_ _tr_ 이렇게 써도 무방하네요.. 가독성을 위해서는 이렇게 쓰는 것도 좋을 듯 합니다 ㅋ

    답글삭제