日期:2014-05-17  浏览次数:20788 次

table没有网格线
突然发现,为什么table没有网格线呢?怎么设置?

------解决方案--------------------
<table border="1">
------解决方案--------------------
table{ border:1px solid #515151; border-collapse:collapse;}
table tr td{ border-bottom:1px solid #515151; border-right:1px solid #515151;;line-height:23px; empty-cells:show}
------解决方案--------------------
CSS代码
<style>
table{
     border-collapse: collapse;/* 边框合并属性  */
 width:200px;
}
th{
     border: 1px solid #666666;
}
td{
     border: 1px solid #666666;
}
</style>HTML代码
<table>
<tr>
<th>姓名</th>
<th>年龄</th>
</tr>
<tr>
<td>www.865171.cn</td>
<td>24</td>
</tr>
<tr>
<td>www.865171.cn</td>
<td>25</td>
</tr>
<tr>
<td>www.865171.cn</td>
<td>23</td>
</tr>
</table>

------解决方案--------------------
需要设置为
<table cellpadding="0" cellspacing="1"></table>
这样就没有间隙了;如图所示:

更多table边框美化请参考http://blog.sina.com.cn/s/blog_5f08aea001019qmd.html

padding 属性定义元素的内边距。padding 属性接受长度值或百分比值,但不允许使用负值。
margin 属性设置一个元素所有外边距的宽度,或者设置各边上外边距的宽度。如图所示: