首页
矢量素材
PNG图标
JS代码
网页小图标
网页素材
设计欣赏
广告达人
有趣新鲜
技术文档
懒人博客
懒人论坛
当前位置:
首页
>
JS代码
>
JS特效代码
>
表格图层
> 第1页
给表格加上滚动条
VIEW:445
来源:懒人图库
2009-06-05
<html> <head> <title>My table</title> <style> .table0 { height:90%; } .table0 caption{ width:100%; height:26px; line-height:26px; font-size:20px; font-color:black; font-weight:900; letter-spacing:5px; } .table0 thead td { text-align:center; vertical-align:middle; height:20px; line-height:18px; font-size:14px; font-color:black; font-weight:bold; padding-top:2px; padding-bottom:2px; border:#555 1px solid; margin:0px; } .table0 tfoot td{ text-align:left; vertical-align:middle; height:20px; line-height:18px; font-size:12px; font-color:black; font-weight:bold; padding-top:2px; padding-bottom:2px; padding-left:12px; padding-right:12px; border:#555 1px solid; } .table0 tbody td { width:100%; height:auto; border:#555 1px solid; padding:0px; margin:0px; } .table1 tbody td { text-align:left; vertical-align:middle; height:20px; line-height:18px; font-size:14px; font-color:#444; font-weight:normal; padding-top:2px; padding-bottom:2px; padding-left:12px; padding-right:12px; border-right:#555 1px solid; border-bottom:#555 1px solid; overflow:hidden; text-overflow:ellipsis; word-break:keep-all; word-wrap:normal; } </style> <script> function init(){ theT=createTable("我的收藏夹",["Group:150","Name:300","URL:200","Visited:100","Modify:100","Delete:100"]); //参数说明:createTable(strCaption,colHeads) //strCaption 标题 //colHeads 是一个array,每个item的格式是 名称:宽度 的字符串 for(var i=0;i<40;i++){ theR=theT.insertRow(); for(var j=0;j<7;j++){ theC=theR.insertCell(); theC.innerText=j; } } } function createTable(strCaption,colHeads){ //参数说明:colHeads 是一个array,每个item的格式是 名称:宽度 的字符串 //生成表格 oTable=document.createElement("table"); document.body.insertBefore(oTable); //设置class oTable.className="table0"; with(oTable.style){ tableLayout="fixed"; borderCollapse="collapse" borderSpacing="0px"; } //设置变量 oTCaption=oTable.createCaption(); oTHead=oTable.createTHead(); oTFoot=oTable.createTFoot(); //生成标题 oTCaption.innerText=strCaption; //设置列宽 oTHead.insertRow(); for(var i=0;i<colHeads.length;i++){ tHeadName=colHeads[i].split(":")[0]; tHeadWidth=isNaN(parseInt(colHeads[i].split(":")[1]))?"auto":parseInt(colHeads[i].split(":")[1]); theCell=oTHead.rows[0].insertCell(); theCell.style.width=tHeadWidth; } theCell=oTHead.rows[0].insertCell(); theCell.width=20; oTHead.rows[0].style.display="none"; //生成表头 oTHead.insertRow(); for(var i=0;i<colHeads.length;i++){ tHeadName=colHeads[i].split(":")[0]; tHeadWidth=isNaN(parseInt(colHeads[i].split(":")[1]))?"auto":parseInt(colHeads[i].split(":")[1]); theCell=oTHead.rows[1].insertCell(); theCell.innerText=tHeadName; theCell.style.width=tHeadWidth; } theCell=oTHead.rows[1].insertCell(); theCell.width=24; //生成表脚 oTFoot.insertRow(); theCell=oTFoot.rows[0].insertCell(); theCell.innerHTML="<marquee scrollDelay=50 scrollAmount=2>Copy rights 2005. Hutia presents.</marquee>"; theCell=oTFoot.rows[0].insertCell(); theCell.colSpan=colHeads.length-1; theCell=oTFoot.rows[0].insertCell(); theCell.width=20; //生成主体 oTable.all.tags("Tbody")[0].insertRow(); theCell=oTable.all.tags("Tbody")[0].rows[0].insertCell(); theCell.colSpan=colHeads.length+1; oMain=document.createElement("DIV"); theCell.insertBefore(oMain); with(oMain.style){ width="100%"; height="100%"; overflowY="auto"; overflowX="hidden"; margin="0px"; marginLeft="-1px"; } oTBody=document.createElement("table"); oMain.insertBefore(oTBody); oTable.oTBody=oTBody; //禁止选择 oTCaption.onselectstart=oTHead.onselectstart=oTFoot.onselectstart=function(){return(false);} //设置class oTBody.className="table1"; with(oTBody.style){ width=oTable.offsetWidth-15; tableLayout="fixed"; borderCollapse="collapse" borderSpacing="0px"; padding="0px"; margin="0px"; } //初始化列宽 oTBody.insertRow(); for(var i=0;i<colHeads.length;i++){ tHeadWidth=isNaN(parseInt(colHeads[i].split(":")[1]))?"auto":parseInt(colHeads[i].split(":")[1]); theCell=oTBody.rows[0].insertCell(); theCell.style.width=tHeadWidth; } oTBody.rows[0].style.display="none"; return(oTBody); } function insertRow(){ var intL=oTBody.rows.length; theRow=oTBody.insertRow(); theRow.index=intL; theRow.onmouseover=rowOnMouseOver; theRow.onmouseout=rowOnMouseOut; theRow.onclick=rowOnClick; for(var i=0;i<colHeads.length;i++){ theCell=theRow.insertCell(); theCell.tabIndex=0; theCell.hideFocus=true; theCell.colIndex=i; theCell.onmouseover=function(){this.focus();}; theCell.onmouseout=cellOnBlur; theCell.onfocus=cellOnFocus; theCell.onblur=cellOnBlur; } theRow.cells[0].innerText=strGroup?strGroup:"ROOT"; theRow.cells[1].innerText=strName?strName:"Untitled Document."; theRow.cells[2].innerText=strURL?strURL:"Unspecified URL"; theRow.cells[3].innerHTML=strVisited?"Yes".fontcolor("red"):"Unknow"; theRow.cells[4].innerHTML=strModify?"Yes".fontcolor("red"):"No".fontcolor("Green"); theRow.cells[5].innerHTML="Delete".fontcolor("red"); } </script> </head> <body onload="init();"> <p>查找更多代码,请访问:<a href="http://www.lanrentuku.com" target="_blank">懒人图库</a></p> </body> </html>
提示:您可以先修改部分代码再运行,复制代码和保存代码功能在Firefox下无效。
很适合做一些数据类型的表
↑上一篇:
随机图片效果
↓下一篇:
表格颜色渐变效果
AJAX仿EXCEL表格功能
玩转表格之表格边框魔鬼教程
给表格做链接
无图片的圆角表格
用CSS控制表格的交替颜色
可拖动的弹出层提示效果
AJAX可以拖动的DIV块
表格颜色渐变效果
给表格加上滚动条
广告代码
共
338
个JS广告代码
››全部
焦 点 图(156)
全屏广告(11)
对联广告(6)
在线客服(5)
相册代码(39)
菜单导航(32)
TAB标签(13)
悬浮漂浮(3)
视频播放(4)
图片特效(23)
翻牌书角(7)
其他代码(39)
特效代码
共
273
个JS特效代码
››全部
导航菜单(55)
表单按钮(43)
文字特效(11)
表格图层(35)
图片特效(15)
时间日期(21)
滚动代码(11)
窗口特效(8)
颜色背景(2)
网站常用(42)
CSS样式(13)
其他特效(17)
最近浏览过的特效代码
更多››
关于我们
-
版权声明
-
广告服务
-
懒人西西
-
RSS订阅
-
工作机会
-
网站地图
-
友情链接
-
联系我们
-
在线留言
Copyright © 2006-2009
lanrentuku.com
All Rights Reserved.
-
京ICP备08001501号