table如何设置边框

table如何设置边框:

1.通过table标签的属性来设置,border="1" 边框设置为1,cellspacing="0" 单元格间距设置为0.

,效果如图

table如何设置边框_第1张图片

2.通过css样式设置,而且用css可以自动设置边框的粗细、颜色等。

table{
    border-top: 1px solid #000000;
    border-left: 1px solid #000000;
    border-collapse: collapse; /*设置单元格的边框合并为1*/
}
td{
    border-bottom: 1px solid #000000;
    border-right: 1px solid #000000;
}

table如何设置边框_第2张图片

表格的隔行变色:

table tr:nth-child(odd){background:#F4F4F4;} //奇数
table tr:nth-child(even){color:#C00;} //偶数

 

你可能感兴趣的:(html,css)