首页
精品网站
艺术设计
网络学院
信息中心
求职招聘
网站综合
服装网站
编程开发
设计论坛
投稿
我要上榜
设计资源站
平面设计
画册
VI欣赏
包装
CG-插画
搜索
个人网页
Alexa排名
CSS
建站资源
下载专区
JS特效
品牌服装
服装院校
专题欣赏
SEO
图标欣赏
专题
网站建设
域名注册
网站建设
虚拟主机
广州网站设计
域名注册
广州网站建设
上海网站建设
虚拟主机
广州网页设计
虚拟主机
域名注册
acg王国
ACG玩家
品牌设计
上海网站建设
当前位置:
网络学院首页
>>
设计教程
>>
DIV特效代码
>> table美化鼠标滑动单元格变色效果
table美化鼠标滑动单元格变色效果
网站色彩搭配讲解
跟我探索网站排名的捷径
网页banner设计欣赏
网站装饰图标设计欣赏
设计赛事集合
ACG王国
来源:
中国设计秀
作者:
点击:
985
加入收藏
关键字:
鼠标
单元格
WEB标准
css
代码如下:[点击运行,可预览效果]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<a href="http://www.w3.org/TR/html4/strict.dtd" target="_blank">http://www.w3.org/TR/html4/strict.dtd</a>"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>orbitz-like behavior for hovering over table cells</title> <style type="text/css"> .cssguycomments {background:#eee;border:#ddd;padding:8px;margin-bottom:40px;} .cssguycomments p {font:normal 12px/18px verdana;} table {border-collapse:collapse;} thead th { font:bold 13px/18px georgia; text-align:left; background:#fff4c6; color:#333; padding:8px 16px 8px 8px; border-right:1px solid #fff; border-bottom:1px solid #fff; } thead th.null {background:#fff;} tbody th { font:bold 12px/15px georgia; text-align:left; background:#fff9e1; color:#333; padding:8px; border-bottom:1px solid #f3f0e4; border-right:1px solid #fff; } tbody td { font:normal 12px/15px georgia; color:#333; padding:8px; border-right:1px solid #f3f0e4; border-bottom:1px solid #f3f0e4; } /* 这3个是关键 --cssrain.cn */ tbody td.on {background:green;} thead th.on {background:red;} tbody th.on {background:red;} </style> <script type="text/javascript"> /* For functions getElementsByClassName, addClassName, and removeClassName Copyright Robert Nyman, <a href="http://www.robertnyman.com" target="_blank">http://www.robertnyman.com</a> Free to use if this text is included */ function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } function getElementsByClassName(className, tag, elm){ var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)"); var tag = tag || "*"; var elm = elm || document; var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag); var returnElements = []; var current; var length = elements.length; for(var i=0; i<length; i++){ current = elements[i]; if(testClass.test(current.className)){ returnElements.push(current); } } return returnElements; } function addClassName(elm, className){ var currentClass = elm.className; if(!new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i").test(currentClass)){ elm.className = currentClass + ((currentClass.length > 0)? " " : "") + className; } return elm.className; } function removeClassName(elm, className){ var classToRemove = new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i"); elm.className = elm.className.replace(classToRemove, "").replace(/^\s+|\s+$/g, ""); return elm.className; } function makeTheTableHeadsHighlight() { // get all the td's in the heart of the table... var table = document.getElementById('rockartists'); var tbody = table.getElementsByTagName('tbody'); var tbodytds = table.getElementsByTagName('td'); // and loop through them... for (var i=0; i<tbodytds.length; i++) { // take note of their default class name tbodytds[i].oldClassName = tbodytds[i].className; // when someone moves their mouse over one of those cells... tbodytds[i].onmouseover = function() { // attach 'on' to the pointed cell addClassName(this,'on'); // attach 'on' to the th in the thead with the same class name var topheading = getElementsByClassName(this.oldClassName,'th',table); addClassName(topheading[0],'on'); // attach 'on' to the far left th in the same row as this cell var row = this.parentNode; var rowheading = row.getElementsByTagName('th')[0]; addClassName(rowheading,'on'); } // ok, now when someone moves their mouse away, undo everything we just did. tbodytds[i].onmouseout = function() { // remove 'on' from this cell removeClassName(this,'on'); // remove 'on' from the th in the thead var topheading = getElementsByClassName(this.oldClassName,'th',table); removeClassName(topheading[0],'on'); // remove 'on' to the far left th in the same row as this cell var row = this.parentNode; var rowheading = row.getElementsByTagName('th')[0]; removeClassName(rowheading,'on'); } } } addLoadEvent(makeTheTableHeadsHighlight); </script> </head> <body> <div class="cssguycomments"> <p>Final example with JavaScript applied. Hover over a table cell to see effects. "View Source" and copy if you'd like to use.</p> </div> <table id="rockartists"> <thead> <tr> <th class="null"> </th> <th class="stones">Rolling Stones</th> <th class="u2">U2</th> <th class="crue">Mötley Crüe</th> </tr> </thead> <tbody> <tr> <th>Lead Vocals</th> <td class="stones">Mick Jagger</td> <td class="u2">Bono</td> <td class="crue">Vince Neil</td> </tr> <tr> <th>Lead Guitar</th> <td class="stones">Keith Richards</td> <td class="u2">The Edge</td> <td class="crue">Mick Mars</td> </tr> <tr> <th>Bass Guitar</th> <td class="stones">Ron Wood</td> <td class="u2">Adam Clayton</td> <td class="crue">Nikkie Sixx</td> </tr> <tr> <th>Drums</th> <td class="stones">Charlie Watts</td> <td class="u2">Larry Mullen, Jr.</td> <td class="crue">Tommy Lee</td> </tr> </tbody> </table> </body> </html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
2008-07-18 00:29:00 出处:
中国设计秀cnwebshow.com
输入您的搜索字词
提交搜索表单
本文引用地址:
http://www.cnwebshow.com/edu/html/article_4981.html
热点文章/相关文章
css代码:网页圆角的做法
@import在IE下的闪烁BUG
XHTML+CSS兼容性解决方案小集
全面了解CSS内置颜色(color)值
CSS网页代码隔行换色的实现编写技巧
WEB标准中如何优化你的CSS代码?
CSS样式表文件的优化及其技巧
网页设计中CSS加载方式对页面优化的影响
!important在ie7.0的hack方法
web标准:CSS clear的属性及使用方法
提高CSS的网页渲染11点注意项
素材下载
矢量
潮流素材
背景素材
模板
最新文章
·
CSS+DIV实现鼠标经过背景变色
·
怎么样用CSS和图片做漂亮搜索框
·
CSSfilter实现漂亮的鼠标滑过图...
·
用css中sprite技术制作的menu效果
·
DIV实现的鼠标路过的表格行变幻...
·
文本框与DIV实现的滚动浏览效果
·
table美化鼠标滑动单元格变色效果
·
CSS实现的表单提示效果
·
实现google的一个效果
·
css3背景定位运用实例
艺术设计秀最新图片
德国设计大师乌韦...
国外精美包装设计...
国外Giesser画册设...
十字绣品牌VI设计...
Radio 103平面广告...
R. Klanten、L. F...
推荐文章
网站地图
|
关于我们
|
联系我们
|
网站建设
|
广告服务
|
版权声明
|
免责声明
|
网站公告
|
友情链接
|
留言
|
旧版入口
Copyright © 2005-2008
中国设计秀_网页设计秀_艺术设计秀_网页设计教程_网站建设作品_平面设计欣赏_包装设计欣赏_品牌网站建设
All Right Reserved.
做最专业的设计服务网站,秀出自我,秀出精彩!
中国设计秀,秀---无处不在!!
交流群:9107036 3848215 8850631
粤ICP备05067046号