简单的表格效果
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>简单的表格效果</title>
<style>
table{
background-color: #fff;
border: none;
color: #565;
font: 12px arial;
text-align: left;
}
table caption{
font-size: 24px;
border-bottom: 2px solid #B3DE94;
border-top: 2px solid #B3DE94;
}
table, td, th{
margin: 0;
padding: 0;
vertical-align: middle;
}
tbody td, tbody th{
background: #DFC;
border-bottom: 2px solid #B3DE94;
border-top: 3px solid #FFFFFF;
padding: 9px;
}
tfoot td, tfoot th{
font-weight: bold;
padding: 4px 8px 6px 9px;
text-align: center;
}
thead th{
font-size: 14px;
font-weight: bold;
line-height: 19px;
padding: 0 8px 2px;
text-align: center;
}
tbody tr.even th, tbody tr.even td{
background-color: #CEA;
border-bottom: 2px solid #67BD2A;
}
col.price{
text-align: right;
}
</style>
</head>
<body>
<table summary="book list">
<caption>Book List</caption>
<col></col><col></col><col></col><col class="price" align="right"></col><col></col>
<thead>
<tr>
<th >Title</th>
<th >ID</th>
<th >Country</th>
<th >Price</th>
<th >Download</th>
</tr>
</thead>
<tbody>
<tr >
<th class="even">Tom</th>
<td>1213456</td>
<td>Germany</td>
<td>$3.12</td>
<td>Download</td>
</tr>
<tr class="odd">
<th >Chance</th>
<td>1213457</td>
<td>Germany</td>
<td>$123.34</td>
<td>Download</td>
</tr>
<tr class="even">
<th >John</th>
<td>1213458</td>
<td>Germany</td>
<td>$34.37</td>
<td>Download</td>
</tr>
<tr class="odd">
<th >oKathleen</th>
<td>1213459</td>
<td>Germany</td>
<td>$23.67</td>
<td>Download</td>
</tr>
</tbody>
<tfoot>
<tr>
<th >Total</th>
<td colspan="4">4 books</td>
</tr>
</tfoot>
</table>
</body>
</html>
IE6下变换table颜色的TD
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>IE6下变换table颜色的TD</title>
<style>
table{
color: #565;
font: 12px arial;
}
td{
background-color: #DFC;
border-bottom: 2px solid #BED394;
border-top: 3px solid #fff;
padding: 9px;
}
tr:hover, tr.hover{
background-color: #595;
color: #fff;
}
</style>
</head>
<body>
<table summary="book list">
<caption>Book List</caption>
<tr >
<td >Title</td>
<td>ID</td>
<td>Contry</td>
<td>Price</td>
<td>Download</td>
</tr>
<tr >
<td >Tom</td>
<td>1213456</td>
<td>Germany</td>
<td>$3.12</td>
<td>Download</td>
</tr>
<tr>
<td >Chance</td>
<td>1213457</td>
<td>Germany</td>
<td>$123.34</td>
<td>Download</td>
</tr>
<tr >
<td >John</td>
<td>1213458</td>
<td>Germany</td>
<td>$34.37</td>
<td>Download</td>
</tr>
<tr>
<td>oKathleen</td>
<td>1213459</td>
<td>Germany</td>
<td>$23.67</td>
<td>Download</td>
</tr>
</table>
<script language="javascript">
var rows = document.getElementsByTagName('tr');
for (var i=0;i<rows.length;i++){
rows[i].onmouseover = function(){ //鼠标指针在行上面的时候
this.className = 'hover';
}
rows[i].onmouseout = function(){ //鼠标指针离开时
this.className = '';
}
}
</script>
</body>
</html>
实现表格变换该行和该列的第一个单元格的颜色
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>实现表格变换该行和该列的第一个单元格的颜色</title>
<style>
table{
color: #565;
font: 12px arial;
}
td{
background-color: #DFC;
border-bottom: 2px solid #BED394;
border-top: 3px solid #fff;
padding: 9px;
}
td.hover{
background-color: #595;
color: #fff;
}
</style>
</head>
<body>
<table summary="book list">
<caption>Book List</caption>
<tr >
<td >Title</td>
<td>ID</td>
<td>Contry</td>
<td>Price</td>
<td>Download</td>
</tr>
<tr >
<td >Tom</td>
<td>1213456</td>
<td>Germany</td>
<td>$3.12</td>
<td>Download</td>
</tr>
<tr>
<td >Chance</td>
<td>1213457</td>
<td>Germany</td>
<td>$123.34</td>
<td>Download</td>
</tr>
<tr >
<td >John</td>
<td>1213458</td>
<td>Germany</td>
<td>$34.37</td>
<td>Download</td>
</tr>
<tr>
<td>oKathleen</td>
<td>1213459</td>
<td>Germany</td>
<td>$23.67</td>
<td>Download</td>
</tr>
</table>
<script language="javascript">
var cells = document.getElementsByTagName('td');
for (var i=0;i<cells.length;i++){
cells[i].onmouseover = function(){ //鼠标指针在行上面的时候
this.className = 'hover';
for(var j = 0;j < cells.length;j++){
if(cells[j] == this){
//该列的第一个单元格编号
cells[j % 5].className = 'hover';
//该行的第一个单元格编号
cells[j - j % 5].className = 'hover';
}
}
}
cells[i].onmouseout = function(){ //鼠标指针离开时
this.className = '';
for(var j = 0;j < cells.length;j++){
if(cells[j] == this){
cells[j % 5].className = '';
cells[j - j % 5].className = '';
}
}
}
}
</script>
</body>
</html>