当前位置:软件学堂 > 资讯首页 > 网络编程 > DIV+CSS > css通过mouse事件制作变色的单元格

css通过mouse事件制作变色的单元格

2012/11/26 10:46:50作者:佚名来源:网络

移动端

【实例介绍】

css通过mouse事件制作变色的单元格

对于长时间审核大量数据、浏览表格的用户来说,即使是隔行变色的表格,阅读时间长了
仍然会感到疲劳。如果数据行能够动态的根据鼠标经过来变色,就使得页面充满了生机,最大
程度地减少用户疲倦。只用简单的Jayascript代码即可实现。

【实例代码】

<!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=utf-8" /> <title>通过mouse事件制作变色的单元格</title> </head> <body> <table width="300" border="1" cellpadding="3" cellspacing="0" bordercolor="#efefef" bgcolor="#efefef">   <tr>     <td onMouseOut="this.bgColor='#efefef';this.borderColor='#efefef'"; onMouseOver="this.bgColor='#cccccc'; this.borderColor='#000033'"> 北京市     19612368 </td>   </tr>   <tr>     <td onMouseOut="this.bgColor='#efefef';this.borderColor='#efefef'"; onMouseOver="this.bgColor='#cccccc'; this.borderColor='#000033'"> 天津市   12938224 </td>   </tr>   <tr>     <td onMouseOut="this.bgColor='#efefef';this.borderColor='#efefef'"; onMouseOver="this.bgColor='#cccccc'; this.borderColor='#000033'"> 上海市     23019148 <br /></td>   </tr> </table> </body> </html>

【代码分析】

onMouseOut="this.bgColor='#efefef';this.borderColor=’#efefef";设置鼠标离开效果。
onMouseOver="this.bgColor='#cccccc';this.borderColor='#000033'";设置鼠标放上去的效果。
可以修改颜色的值来改变颜色,预览效果如图所示。

mouse事件
 【素材及源码下载】

请点击:通过mouse事件制作变色的单元格 下载本实例相关素材及源码

 

标签: mouse