有一表格,用css如何設置當鼠標停在某行時改變背景色?
<style type= "text/css ">
table td,th {
border:1px solid blue;
padding:2px 2px 2px 2px ;
background-color:lightgreen;
}
tr:hover {
background-color:#FF00CC;
}
</style>
</head>
<body>
<table>
<tr>
<th> 学号 </th>
<th> 姓名 </th>
<th> 年龄 </th>
<th> 班级 </th>
</tr>
<tr>
<td> 012 </td>
<td> 某某 </td>
<td> 23 </td>
<td> 计科0102 </td>
</tr>
<tr restudy= " ">
<td> 012 </td>
<td> 某某 </td>
<td> 23 </td>
<td> 计科0102 </td>
</tr>
<tr>
<td> 012 </td>
<td> 某某 </td>
<td> 23 </td>
<td> 计科0102 </td>
</tr>
<tr>
<td> 012 </td>
<td> 某某 </td>
<td> 23 </td>
<td> 计科0102 </td>
</tr>
</table>
</body>
第八行是想讓鼠標停在某行時改變背景色為淺紅,為什麼不起作用,怎麼寫?
我用的是ie6
------解决方案--------------------嗯,IE6不支持这样的方式,不过如果在FF底下就可以。
如果需要让它变色,需要加js进去。参考下边这个看看~
======================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> Basic Info </title>
<meta http-equiv= "Content-Type " content= "text/javascript; charset=gb2312 " />
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "JavaScript " />
<meta name= "keywords " content= "Practise " />
<meta name= "description " content= "just a practice of the javascript " />
<style>
#wrap{
margin: 10px 50px;
}
thead{
color: #fff;
background: #1391a8;
}
tr{
line-height: 27px;
}
.sty1{
color: #1391a8;
background: #e3efef;
}
.sty2{
color: #fff;
background: #72cfd7;
}
.over{
color: #fff;
background: #ffbb1c;
}
td{
padding-left: 15px;
padding-right: 15px;
}
button{
margin: 0 10px 0 0;
}
</style>
<script>
function cc(obj){
obj.className += " over ";
}
function bc(obj){
obj.className = obj.className.replace(new RegExp( "( ?|^)over\\b "), " ");
}
</script>
</head>
<body>
<div id= "wra