table如何設(shè)置邊框:
1.通過table標(biāo)簽的屬性來設(shè)置,border="1" 邊框設(shè)置為1,cellspacing="0" 單元格間距設(shè)置為0.
<table border="1" cellspacing="0"></table>,效果如圖
2.通過css樣式設(shè)置,而且用css可以自動(dòng)設(shè)置邊框的粗細(xì)、顏色等。
- table{
- border-top: 1px solid #000000;
- border-left: 1px solid #000000;
- border-collapse: collapse; /*設(shè)置單元格的邊框合并為1*/
- }
- td{
- border-bottom: 1px solid #000000;
- border-right: 1px solid #000000;
- }
或
- table td{
- border-bottom: 1px solid #000000;
- border-right: 1px solid #000000;
- }
- table tr:first-child td{
- border-top: 1px solid #000000;
- }
- table tr td:first-child{
- border-left: 1px solid #000000;
- }
表格的隔行變色:
- table tr:nth-child(odd){background:#F4F4F4;} //奇數(shù)
- table tr:nth-child(even){color:#C00;} //偶數(shù)
聯(lián)系客服