首先头文件定义样式,我的比较挫
table {
border-collapse: collapse;
margin: 0 auto;
text-align: center;
width: 90%
}
table td, table th {
border: 1px solid #cad9ea;
color: #666;
height: 30px;
}
table thead th {
background-color: #CCE8EB;
width: 100px;
}
table tr:nth-child(odd) {
background: #fff;
}
table tr:nth-child(even) {
background: #fafafa;
}
/*js实现*/
/*table tr:hover, */
table tr.hilite {
background: #f5f7fa;
}
table tr.select {
background: #8896b3;
}
table tr#select td {
background: #8896b3;
color: #fff;
}
html中定义我们的表格
<body>
<table class="tab