首页 > Web开发 > 详细

html table内容不随标题滚动

时间:2018-11-02 12:38:07      阅读:239      评论:0      收藏:0      [点我收藏+]

<html>
<head>
</head>
<body>
<div>
<div id="demo" style="overflow:auto;height:80px;width:100;position:relative" onscroll="vertical(this)">
<table border="1" style="position:absolute;z-index:2; " bgcolor=#ff00ff width=100% id=t0>
<tr>
<td id="td1">ttt</td>
<td>ttt中国人</td>
<td>ttt</td>
<td>ttt</td>
<td>ttt</td>
</tr>
</table>
<table border="1" cellpadding="1" height="200" bgcolor=#00ff00 width=100% id=t1 style="position:absolute;z-index:0;">
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
</table>
</div>
</div>

<script>
var t0 = document.getElementById(‘t0‘);
function vertical(obj) {
console.log(obj.scrollTop); //该函数未定义
console.log(this.scrollTop);
console.log(obj.scrollLeft);
//console.log(this); //this 是windows对象
t0.style.top = obj.scrollTop;
}


</script>
</body>
</html>

html table内容不随标题滚动

原文:https://www.cnblogs.com/enych/p/9895509.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!