FDS’s Blog

2008年5月23日

用CSS来设置onmouseover和onmouseout事件

Filed under: DIV+CSS — 标签:, — FDS @ 03:14

用CSS来设置onmouseover事件实例:

ul{
/*设置onmouseover事件*/
onmouseover: expression(onmouseover=function (){this.style.borderColor =’#cccccc’;this.style.color=’#ffffff’;this.style.backgroundColor =’#0099ff’});

/*设置onmouseout事件*/
onmouseout: expression(onmouseout=function (){this.style.borderColor=”;this.style.color=”;this.style.backgroundColor =”});
background-color:#ffffff;
}

这段代码实现的功能就是当鼠标移动到ul列表时,背景就会变成蓝色,文字变成白色,边框变成灰色.这种效果一般用在当用UL代替表格时,实现的当整行变换效果!

3 条评论 »

  1. 顶一个,不错,学习了~~~

    评论 by lrj — 2009年6月17日 @ 09:13

  2. td:hover{
    background-color:#3366CC;
    }



    http://www.phplovers.com/html/wangyesheji/2009/0627/onmouseover_onmouseout.html

    评论 by ayanmw — 2010年9月2日 @ 11:16

  3. hover for FireFox only
    expression for IE only

    评论 by ayanmw — 2010年9月2日 @ 11:18

这篇文章上的评论的 RSS feed TrackBack URL

留下评论

Powered by WordPress