定义Table时显示表格边框显示1px

来源:互联网 发布:fix it center 编辑:程序博客网 时间:2024/05/18 01:27

关键属性:border-collapse

 

如果用表格的border="1"属性定义,实际显示的宽度要比1px粗。

所以我直到现在都是定义table的left和top边框,然后定义td的right和bottom边框,这样也用css定义了一个表格的边框。

 

例子:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>定义</title>
<style>
table{ border-collapse:collapse; }
td{ border:#ccc solid 1px; padding:5px; }
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>1px表格边框</td>
    <td>1px表格边框</td>
    <td>1px表格边框</td>
  </tr>
  <tr>
    <td>1px表格边框</td>
    <td>1px表格边框</td>
    <td>1px表格边框</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

 

原创粉丝点击