细边框,border 属性is used for table tag only (在BLOG中直接输入html代码,导致blog布局乱)
Code
通过背景色覆盖的方法
<table align="center" bgcolor="#fff" border="0" cellpadding="0" cellspacing="1" width="80%">
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
</table>
<style type="text/css">
<!--
table{
/*
语法:
border-collapse : separate | collapse
取值:
separate : 默认值。边框独立(标准HTML)
collapse : 相邻边被合并
*/
border-collapse:collapse;
}
td{
background:#ffc;
border:solid 1px #f90;
height:12px;
}
-->
</style>
通过CSS的方法
<table width="80%" align="center">
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
</table>
<pre>
border 属性只对table有作用,tr,td没有作用的
通过CSS来设置tr,td的边框
</pre>
<hr>
<pre>
<p>在HTML中,我们设置border="1" 时,表格边框实际大小是2px,那如果我们要做成1px的细线表格要怎么办?以前在做1px的表格的时候,我会用表格背景颜色,然后再用另一种颜色设计单元格的背景,再把表格间距设置成1px,这样就能达到我们的1px表格了,如下例:</p>
<p><table align="center" bgcolor="#f90" border="0" cellpadding="0" cellspacing="1" width="80%"><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
</table> <br />
这种方法虽然可以实现,但是页面里的代码多了很多,而且要控制局部也相对麻烦些。</p>
<p>下面的这种方法及其简单,html代码也减少了很多,结构更加的清晰。</p>
<p><style type="text/css"><br />
<!--<br />
table{<br />
/*border-collapse:collapse;*/<br />
}<br />
td{<br />
background:#ffc;<br />
border:solid 1px #f90;<br />
height:22px;<br />
}<br />
--><br />
</style><br />
html代码:<br />
<table width="80%" align="center"><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
</table></p>
</pre>
通过背景色覆盖的方法
<table align="center" bgcolor="#fff" border="0" cellpadding="0" cellspacing="1" width="80%">
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
<tr>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
<td bgcolor="white">a</td>
</tr>
</table>
<style type="text/css">
<!--
table{
/*
语法:
border-collapse : separate | collapse
取值:
separate : 默认值。边框独立(标准HTML)
collapse : 相邻边被合并
*/
border-collapse:collapse;
}
td{
background:#ffc;
border:solid 1px #f90;
height:12px;
}
-->
</style>
通过CSS的方法
<table width="80%" align="center">
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
</tr>
</table>
<pre>
border 属性只对table有作用,tr,td没有作用的
通过CSS来设置tr,td的边框
</pre>
<hr>
<pre>
<p>在HTML中,我们设置border="1" 时,表格边框实际大小是2px,那如果我们要做成1px的细线表格要怎么办?以前在做1px的表格的时候,我会用表格背景颜色,然后再用另一种颜色设计单元格的背景,再把表格间距设置成1px,这样就能达到我们的1px表格了,如下例:</p>
<p><table align="center" bgcolor="#f90" border="0" cellpadding="0" cellspacing="1" width="80%"><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
<tr><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
<td bgcolor="#ffc"></td><br />
</tr><br />
</table> <br />
这种方法虽然可以实现,但是页面里的代码多了很多,而且要控制局部也相对麻烦些。</p>
<p>下面的这种方法及其简单,html代码也减少了很多,结构更加的清晰。</p>
<p><style type="text/css"><br />
<!--<br />
table{<br />
/*border-collapse:collapse;*/<br />
}<br />
td{<br />
background:#ffc;<br />
border:solid 1px #f90;<br />
height:22px;<br />
}<br />
--><br />
</style><br />
html代码:<br />
<table width="80%" align="center"><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
<tr><br />
<td></td><br />
<td></td><br />
<td></td><br />
</tr><br />
</table></p>
</pre>
posted on 2009-05-19 18:15 dolphin_bobo 阅读(319) 评论(0) 编辑 收藏 举报