原生的table的常用属性:
//有!DOCTYPE表格属性border-collapse才能兼容ie8。

代码如下 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>table 的常用属性</title>
<style type="text/css">
table{
border-collapse: collapse; /* 会覆盖 cellspacing*/
}
table tr{
background: red;
}
table tr td{
border:1px solid #dfdfdf;
}
</style>
</head>
<body>
<table cellpadding="10px" cellspacing="20">
<thead>
<tr>
<th>姓名</th>
<th>爱好</th>
</tr>
</thead>
<tbody>
<tr>
<td>周杰轮</td>
<td>太多了</td>
</tr>
<tr>
<td>昆菱</td>
<td>喜欢唱歌</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
</script>
</body>
</html>

本文详细介绍了HTML中原生table元素的常用属性及其使用方法,包括如何设置单元格间距、边框折叠等,并通过示例代码展示了如何用CSS样式美化表格,使表格在不同浏览器下保持一致的显示效果。
1402

被折叠的 条评论
为什么被折叠?



