表格的颜色设置非常简单,和文字的颜色设置完全一样。
CSS通过background
/background-color
属性设置表格的背景颜色;通过color属性设置表格中文字的颜色。
示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>年度收入</title> <style> body { background-color: #ebf5ff; margin: 0px; padding: 4px; text-align: center; } table{ background-color:pink; color: white; } </style> </head> <body> <h3>年度收入</h3> <table border="1"> <tr> <th></th> <th scope="col">2004</th> <th scope="col">2005</th> <th scope="col">2006</th> <th scope="col">2007</th> </tr> <tr> <th scope="row">捐款</th> <td>11.980</td> <td>12.650</td> <td>9.700</td> <td>10.600</td> </tr> <tr> <th scope="row">拨款</th> <td>11.980</td> <td>12.650</td> <td>9.700</td> <td>10.600</td> </tr> <tr> <th scope="row">投资</th> <td>11.980</td> <td>12.650</td> <td>9.700</td> <td>10.600</td> </tr> <tr> <th scope="row">募捐</th> <td>11.980</td> <td>12.650</td> <td>9.700</td> <td>10.600</td> </tr> <tr> <th scope="row">销售</th> <td>11.980</td> <td>12.650</td> <td>9.700</td> <td>10.600</td> </tr> </table> </body> </html>
效果图:
更多web前端自学知识,请查阅 HTML中文网 !!