除了背景颜色外,还可以为表格设置背景图像,让表格看上去更加绚丽多彩。
语法
<table background="背景图像的地址">
语法解释
背景图像的地址可以设置为相对地址,也可以设置为绝对地址。
例7.5 实例代码
<html>
<head>
<title>设置表格内文字与边框的间距</title>
</head>
<body>
<table background="images/p1.jpg" bgcolor="#ffcc66" align="center" width="600" border="1"
cellspacing="3" bordercolor="#ff6633" cellpadding="10">
<caption>亚星公司员工通讯录</caption>
<tr>
<th>姓名</th>
<th>地址</th>
<th>电话</th>
<th>电子邮件</th>
</tr>
<tr>
<td>李小米</td>
<td>长春市天富家园</td>
<td>1556890****</td>
<td>483949***@qq.com</td>
</tr>
<tr>
<td>刘潇潇</td>
<td>长春市明珠</td>
<td>1867493****</td>
<td>8474954***@qq.com</td>
</tr>
</table>
</body>
</html>运行这段代码,可以看到表格的背景图像如图7.13所示。
图7.13 设置表格的背景图像