サイト内検索
...スタイルシート(css)...
スタイルシート・table
セル内の背景画像
- セル内の背景画像は、 background-imageプロパティを指定します。
- [使い方]
- th, td{
background-image: url(sample.jpg);
}
プロパティ名 | 値 | 説明 |
---|---|---|
background-image: | ; |
「url(http://・・/sample.jpg);」
のように表示する画像(URL)を指定します。 |
- 外部ファイルで背景画像を表示させる場合
- 背景画像の外部スタイルシートファイル(.css)から見た
- 画像ファイルの相対アドレス(url)を記述します
table要素に
指定 |
全体に背景画像を指定できます。
table{ background-image: url(../sample.jpg); } |
|
||||
tr要素に
指定 |
行単位で指定が出来ます。
tr{ background-image: url(../sample.jpg); } |
|
||||
th,td要素に
指定 |
指定したい所を指定できます。
th,td{ background-image: url(../sample.jpg); } |
|
サンプル
[headの中]
<style type="text/css"><!--
table{
border: 1px #999999 solid;
}
th.sample1, td.sample1{
border: 1px #999999 solid;
background-image: url(sample.jpg);
}
-->
</style>
[bodyの中]
<table><tr>
<th class="sample1">No1</th>
<th>No2</th>
</tr>
<tr>
<td> No3</td>
<td class="sample1">No4</td>
</tr>
</table>
[ブラウザ上]
No1 | No2 |
---|---|
No3 | No4 |