隔行换色代码_CSS结合JavaScript实现_层和布局特效

查看演示效果

CSS结合JavaScript实现的Li隔行换色代码,效果真的不错,不过使用了JavaScript略显麻烦,但是不受Li行数的限制,想添多少行就添多少行,JavaScript帮你判断是否需要换色,省心吧。<!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" mrc="text/html; charset=gb2312" /> <title>Li隔行换色的实现</title> </head><body> <style> .mytable {border-collapse:collapse;border:solid #6AA70B;border-width:0px 0 0 0px;width:50%;} .mytable ul li {padding-top:5px;text-indent:2em;list-style:none;1122123<img src=http://p1.mb5u.com/texiao/3/20100522231351323.gif _fcksavedurl=http://p1.mb5u.com/texiao/3/20100522231351323.gif>2244234background:url(http://p1.mb5u.com/texiao/3/20100522231351323.gif) 3px 50% no-repeat;border-bottom:#6AA70B 1px dotted ;font-family: "Verdana,宋体";font-size: 12px;color:#008000;text-align:left;height:25px;} .mytable ul li.t1 {background-color:#EFFEDD;} .mytable ul li.t2{background-color:#ffffff;} .mytable ul li.t3 {background-color:#D2FCA0;} </style> <body style=margin:0;><br><br><br> <div align="center"> <div class=mytable id=tab> <ul> <li><a href="#">一个XP风格的VC++窗体界面库含示例源程序</a></li> <li><a href="#">Delphi文件锁定源程序示例</a></li> <li><a href="#">jQuery动感图片翻转插件示例版</a></li> <li><a href="#">无第三方控件图片管理系统下载,Delphi直接编译</a></li> <li><a href="#">这个是第5行的文字,大家看清楚了</a></li> <li><a href="#">具有XP界面样式的代码管理器Delphi源代码</a></li> <li><a href="#">这个是第7行的文字,大家看清楚了</a></li> <li><a href="#">VC++图像分水岭分割算法控件及示例源代码</a></li> <li><a href="#">小巧的Delphi生日提醒程序(控件版)</a></li> </ul></div><script type="text/javascript"> <!-- var Ptr=document.getElementById("tab").getElementsByTagName("li"); function $() { for (i=1;i<Ptr.length+1;i++) { Ptr[i-1].className = (i%2>0)?"t1":"t2"; } } window.onload=$; for(var i=0;i<Ptr.length;i++) { Ptr[i].onmouseover=function(){ this.tmpClass=this.className; this.className = "t3"; }; Ptr[i].onmouseout=function(){ this.className=this.tmpClass; }; } //--> </script> </body> </html>

所属频道:层和布局特效/更新时间:2010-06-03
相关层和布局特效

层和布局特效Rss订阅特效代码搜索