HTML下的table滚动实现

作者&投稿:答畏 (若有异议请与网页底部的电邮联系)
如何在html的Table(单元格)中使用滚动条~

给table加固定的宽度和高度,然后加overflow:auto

1.2.3. 4. 5. 0001020304056. 1011121315157. 2021222324258. 3031323334359. 10.11. 12.

1、首先打开myeclipse获取idea这样的编辑器,在编辑器中写一个table标签,这里给出table的值。

2、然后可以在页面中看到此时展示的是没有样式的table样板,此时所有的数据没有经过渲染,比较紧凑,也不是一个页面展示。

3、可以在table中引入样式标签style来设计table的样式。

4、还可以使用内部元素,使用jquery ,在jquery中首先给table一个class属性,在JavaScript中通过.class属性获取这个table,给出样式设计。

5、根据上面的设计再经过背景、宽度、高度的设计,可以设计出一个比较好看的table。



<div style="width:600px; height:700px; overflow:scroll; overflow-x:hidden;">
这里放你的table代码

</div>
其原理是控制宽度在600像素,高度在700像素,显示滚动条并隐藏横向滚动条

把代码保存为html格式, 上传到网页空间看看是不是你想要的!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset= gb2312">
<style type="text/css">
<!--
a
a:hover
td
-->
</style>
<script language=JAVAscript>
<!--
// ------ 定义全局变量
var theNewsNum;
var theAddNum;
var totalNum;
var CurrentPosion=0;
var theCurrentNews;
var theCurrentLength;
var theNewsText;
var theTargetLink;
var theCharacterTimeout;
var theNewsTimeout;
var theBrowserVersion;
var theWidgetOne;
var theWidgetTwo;
var theSpaceFiller;
var theLeadString;
var theNewsState;
function startTicker()
{
// ------ 设置初始数值
theCharacterTimeout = 50;//字符间隔时间
theNewsTimeout = 2000;//新闻间隔时间
theWidgetOne = "_";//新闻前面下标符1
theWidgetTwo = "-";//新闻前面下标符
theNewsState = 1;
//theNewsNum = document.body.children.incoming.children.NewsNum.innerText;//新闻总条数
//add by lin
theNewsNum = document.body.children.incoming.children.AllNews.children.length;//新闻总条数
theAddNum = document.body.children.incoming.children.AddNews.children.length;//补充条数
totalNum =theNewsNum+theAddNum;
theCurrentNews = 0;
theCurrentLength = 0;
theLeadString = " ";
theSpaceFiller = " ";
runTheTicker();
}
// --- 基础函数
function runTheTicker()
{
if(theNewsState == 1)
{
if(CurrentPosion<theNewsNum){
setupNextNews();
}
else{
setupAddNews();
}
CurrentPosion++;
if(CurrentPosion>=totalNum||CurrentPosion>=5) CurrentPosion=0; //最多条数不超过5条
}
if(theCurrentLength != theNewsText.length)
{
drawNews();
}
else
{
closeOutNews();
}
}
// --- 跳转下一条新闻
function setupNextNews()
{
theNewsState = 0;
theCurrentNews = theCurrentNews % theNewsNum;
theNewsText = document.body.children.incoming.children.AllNews.children[theCurrentNews].children.Summary.innerText;
theTargetLink = document.body.children.incoming.children.AllNews.children[theCurrentNews].children.NewsLink.innerText;
theCurrentLength = 0;
document.all.hottext.href = theTargetLink;
theCurrentNews++;
}
function setupAddNews()
{
theNewsState = 0;
theCurrentNews = theCurrentNews % theAddNum;
theNewsText = document.body.children.incoming.children.AddNews.children[theCurrentNews].children.Summary.innerText;
theTargetLink = document.body.children.incoming.children.AddNews.children[theCurrentNews].children.NewsLink.innerText;
theCurrentLength = 0;
document.all.hottext.href = theTargetLink;
theCurrentNews++;
}
// --- 滚动新闻
function drawNews()
{
var myWidget;
if((theCurrentLength % 2) == 1)
{
myWidget = theWidgetOne;
}
else
{
myWidget = theWidgetTwo;
}
document.all.hottext.innerHTML = theLeadString + theNewsText.substring(0,theCurrentLength) + myWidget + theSpaceFiller;
theCurrentLength++;
setTimeout("runTheTicker()", theCharacterTimeout);
}
// --- 结束新闻循环
function closeOutNews()
{
document.all.hottext.innerHTML = theLeadString + theNewsText + theSpaceFiller;
theNewsState = 1;
setTimeout("runTheTicker()", theNewsTimeout);
}
window.onload=startTicker;
//-->
</script>
</head>
<body>

<script type="text/javascript">
var vjAcc="860010-0120120000";
vjTrack();
</script>
<noscript>
<img src="" width="1" height="1" />
</noscript>
<table>
<tr><td>
<div id=visible>你的文字说明:<a href="" id=hottext target="_blank"></a></div>
</td></tr>
</table>
<div id=incoming style="DISPLAY: none">
<div id=AllNews>

如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!

vaela

用<marquee></marquee>标签不久行了 呵呵


个旧市18251741755: HTML下的table滚动实现 -
栋鱼丁络: <div style="width:600px; height:700px; overflow:scroll; overflow-x:hidden;"> 这里放你的table代码</div> 其原理是控制宽度在600像素,高度在700像素,显示滚动条并隐藏横向滚动条

个旧市18251741755: 如何在html的Table中使用滚动条 -
栋鱼丁络: 单元格里一样的设置 css 属性 table.scrollable td { overflow: scroll; }.....如果我的回答没能帮助您,请继续追问.

个旧市18251741755: HTML怎么给table添加滚动条 -
栋鱼丁络: 1. 2.3. 4. 5. 000102030405 6. 101112131515 7. 202122232425 8. 303132333435 9. 10. 11. 12.

个旧市18251741755: html中表格水平和垂直滚动,表头垂直不动,可以水平滚动,大神们请问怎么实现啊? -
栋鱼丁络: 用两个table,一个做表头,一个放内容

个旧市18251741755: html上面的一个table 如何实现,滚动条左右滚动的时候,第一列固定;上下滚动的时候第一行固定; -
栋鱼丁络: 你可以尝试把第二行第二列做成一个新表.然后在设置滚动条

个旧市18251741755: 怎么在网页中实现表格上下左右滚动 -
栋鱼丁络: 怎么在网页中实现表格上下左右滚动 给该表格添加固定宽度和高度,切忌不可太大,然后添加css代码,如: table{ width:200px; height:200px; overflow:scroll}

个旧市18251741755: 怎么实现html table前几列不滚动,之后的列滚动,后几列和行都是动态生成的. -
栋鱼丁络: 滚动字幕的标签是,网上有相关资料的可以看看 动态生成的就在动态生成的代码中把标签放在最外层

个旧市18251741755: HTML或JS代码如何实现让一个table的表头不动,body可以自由上下左右滚动,同时保持表头与body的宽度一致? -
栋鱼丁络: 可以下载一个supertable的JS-jquery组件看看.原理是把一个table拆成四个div,简单说就是把滚动的部分悬停固定部分之上.比如克隆一个表头出来(DIV),然后设置全表的那个DIV上移一个表头高度,这样滚动表体而表头不动.左右的原理一样.自己也可以写,不过需要计算好几个DIV的运动关系.

个旧市18251741755: html中 怎么让table第一行固定其他行可滚动 并且滚动条不超出第一行的宽度 然后各列与第一行各列对齐 -
栋鱼丁络: 换个思路.用两个table,第一个table显示你所说的第一行内容,第二个table显示其他行,让第二个table内容滚动不就行了?仅提供思路.

个旧市18251741755: html中,怎么实现这样的一个表格? -
栋鱼丁络: <style type="text/css"> *{ padding:0px; margin: 0px; } #thead { /*固定表头*/ position:fixed; /* 表头显示层次高于表体,防止空白行和表头重合时出现重影*/ z-index:2; background:#ECECFF; } #spacetr{ /* 空白的tr 用来填补表头遮盖的数据*/ ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网