テーブル(表)





HTML4 スタイルシート
文章や画像の回りこみ <table align="位置">

■位置
left (表を)ウインドウの左側に配置
center ウインドウの中央に配置
right ウインドウの右側に配置

▼回り込んだテキストとの余白

Netscapeのみ
<table align="位置" vspace="上下の余白" hspace="左右の余白">
table { float: left }
(左右のみ)

▼回り込んだテキストとの余白

table {
float: left;
margin: 20px 10px (上下に20px、左右に10pxの余白)
}

セルとセルの間隔 <table cellspacing="20"> Netscape Navigator 6のみ
table { border-spacing: 20px }(上下左右)
table { border-spacing: 20px 10px }(左右20px 上下10px)
セルとセルの間隔をなくす <table cellspacing="0"> Internet Explore 5以降のみ
table { border-collapse: collapse }
セル内の余白 <table cellpadding="10"> Netscape Navigator 4.xでは不完全
td, th { padding: 10px }( tableではなく、td, th要素に設定する)
罫線の色 <table bordercolor="#b22222"> table { border-color: #b22222 }

border-top-color、border-bottom-color、border-left-color、border-right-colorで、上、下、左、右の枠線をそれぞれ指定できる。

{border-color: #b22222 #ffff00}と2つの色を指定すると、上下と左右の色、

{border-color: #b22222 #ffff00 #006400}と3つの色を指定すると、上、左右、下、

同様に4つの色を指定すると、上、右、下、左の順に指定できる。
背景の色・背景画像 <table bgcolor="#b22222">
<table background="画像のURL">
(table, tr, td, th要素に指定)
table { background-color: #b22222 }
table { background-image: url('back.gif') }
(table, tr, td, th, col, colgroup, thead, tfoot, tbodyなどに指定)
外枠の表示方法 <table frame="表示形式">

■表示形式
void 外枠なし
above 上辺のみ
below 下辺のみ
hsides 上辺と下辺のみ
vsides 左右両辺のみ
lhs 左辺のみ
rhs 右辺のみ
box 周囲すべて
border 周囲すべて
table { border-top: 太さ 線種 色指定 }

同様に、border-bottom、border-left、border-rightごとに指定、またはborderで四辺一度に指定できる。

■太さ
thin 細線
medium 通常の太さ
thick 太線
数値+単位 5pxなど

■線種
none 枠線なし(初期値)
hidden 枠線なし(表に隣接する線があるときは無効)
solid 実線
dotted 点線
dashed 破線
double 二重線
groove 溝のついた立体線
ridge 隆起線
inset 内側が窪んだ立体線
outset 外側が窪んだ立体線


■色指定
色記号または色名
transparent 透明にする
内枠の表示方法 <table rules="表示形式">

■表示形式
none 罫線なし
rows 行間のみ
cols 列間のみ
all すべての行間及び列間
groups 行グループ、列グループの間
現状ではこれと同じ設定をスタイルシートで行うことは困難。
データの表示位置 ▼対象となるタグ
td, th, tr, col, colgroup, thead, tfoot, tbody

<td align="横位置">
<td valign="縦位置">

■横位置
left 左揃え(初期値)
center 中央揃え
right 右揃え
justify 均等割付

■縦位置
top 上揃え
middle 中央揃え(初期値)
bottom 下揃え
baseline ベースライン揃え
text-align: 行揃え[ブロックレベル要素(p, h, td, th要素)に指定できる]
vertical-align: 上下位置 [インライン要素または表のセル(td, th要素)に指定できる]

■行揃え
left 左揃え(初期値)
center 中央揃え
right 右揃え
justify 均等割付

■縦位置
top 上揃え
middle 中央揃え
bottom 下揃え
baseline ベースライン揃え(初期値)
幅・高さ ▼表の幅を指定
<table width="80%">
("80%"または"100"など)

▼列の幅を指定 (colgroup, col, td, th)
<table width="100">

▼行の高さは原則として指定しない
▼表の幅を指定
table { width: 80% }
("80%"または"100px"など)

▼列の幅を指定 (colgroup, col, td, th)
td { width: 100px }

▼行の高さを指定 (tr)
tr { height: 50px }

セル内で文字を折り返さない <td nowrap>〜</td>
<th nowrap>〜</th>
td {white-space: nowrap}
表タイトルの位置 <caption align="表示位置">〜</caption>

■表示位置
top 表の上中央(初期値)
bottom 表の下中央
right 表の上の右側
left 表の上の左側

caption{
caption-side: bottom; (表タイトルを下部に配置)
text-align: left (表タイトルを左揃え)
}

表を行ごとにグループ化
▼ヘッダ部を定義するとき <thead>〜</thead>
▼フッタ部を定義するとき <tfoot>〜</tfoot>
▼本体を定義するとき <tbody>〜</tbody>
表を列ごとにグループ化
▼その1 <colgroup span="列数">〜</colgroup>
▼その2 <colgroup>
<col span="列数">
<col span="列数">
<col span="列数">
・・・
</colgroup>
(こうすると、列グループごとにデザイン指定できる)
横方向にセルを結合
<td colspan="セル数">〜</td>
<th colspan="セル数">〜</th>
縦方向にセルを結合
<td rowspan="セル数">〜</td>
<th rowspan="セル数">〜</th>







TOP