用CSS怎样实现鼠标移上去表格内的背景颜色变色 求一高手······谢谢···
展开全部
<html>
<head>
<title>鼠标划过表格行变色-简洁实现</title>
<style type="text/css">
#tb{width:666px;border-collapse:collapse;border:1px solid #EEE;font-size:14px;}
#tb th{background:#EEE;border-bottom:1px solid #CCC;padding:4px;}
#tb td{border:1px solid #EEE;padding:4px;}
</style>
</head>
<body>
<table id="tb">
<tr>
<th>商品名称</th>
<th>单价</th>
<th>库存数量</th>
<th>货位</th>
</tr>
<tr>
<td>丁学最喜欢的仙四豪华版-菱纱版</td>
<td>139</td>
<td>10000000</td>
<td>A12-253</td>
</tr>
<tr>
<td>仙四豪华版-梦璃版</td>
<td>139</td>
<td>10000000</td>
<td>A12-254</td>
</tr>
<tr>
<td>仙四普通版-首发</td>
<td>69</td>
<td>10000000</td>
<td>A12-255</td>
</tr>
</table>
<script type="text/javascript">
var obj=document.getElementById("tb");
for(var i=0;i<obj.rows.length;i++){
obj.rows[i].onmouseover=function(){this.style.background="#0EF";}
obj.rows[i].onmouseout=function(){this.style.background="";}
}
</script>
</body>
</html>
<head>
<title>鼠标划过表格行变色-简洁实现</title>
<style type="text/css">
#tb{width:666px;border-collapse:collapse;border:1px solid #EEE;font-size:14px;}
#tb th{background:#EEE;border-bottom:1px solid #CCC;padding:4px;}
#tb td{border:1px solid #EEE;padding:4px;}
</style>
</head>
<body>
<table id="tb">
<tr>
<th>商品名称</th>
<th>单价</th>
<th>库存数量</th>
<th>货位</th>
</tr>
<tr>
<td>丁学最喜欢的仙四豪华版-菱纱版</td>
<td>139</td>
<td>10000000</td>
<td>A12-253</td>
</tr>
<tr>
<td>仙四豪华版-梦璃版</td>
<td>139</td>
<td>10000000</td>
<td>A12-254</td>
</tr>
<tr>
<td>仙四普通版-首发</td>
<td>69</td>
<td>10000000</td>
<td>A12-255</td>
</tr>
</table>
<script type="text/javascript">
var obj=document.getElementById("tb");
for(var i=0;i<obj.rows.length;i++){
obj.rows[i].onmouseover=function(){this.style.background="#0EF";}
obj.rows[i].onmouseout=function(){this.style.background="";}
}
</script>
</body>
</html>
展开全部
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
table {
border-collapse:collapse;
}
td {
border:#000 solid 1px;
}
</style>
</head>
<body>
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
</tr>
<tr>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
table {
border-collapse:collapse;
}
td {
border:#000 solid 1px;
}
</style>
</head>
<body>
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
</tr>
<tr>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
<td onmouseover="this.style.background='#666666'" onmouseout="this.style.background=''"> </td>
</tr>
</table>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询