如何让网页表格里的图片,自动适应边框

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:52:13
<head>
<meta http-equiv="Content-Language" content="zh-cn">
</head>

<table border="1" width="270" height="70" id="table1">
<tr>
<td><img border="0" src="http://www.baidu.com/123.jpg"></td>
</tr>
</table>

像上面那代码,123.jig实际大小是250X60,这效果是图片在表格的左上,而且紧靠边。这么让图片居中,并且距离表格上下空的的地方一般大啊。

<head>
<meta http-equiv="Content-Language" content="zh-cn">
</head>

<table border="1" width="270" height="70" id="table1">
<tr>
<td align="center" valign="middle"><img border="0" src="http://www.baidu.com/123.jpg"></td>
</tr>
</table>

在 <td> 标签里定义 align 的属性 center 居中

<td align="center"><img border="0" src="http://www.baidu.com/123.jpg"></td>